Use PDIs? Take our 5-minute survey to help shape the PDI roadmap.

Client Script onChange is not triggering at all

colin-lucwe
Tera Contributor

Hi everyone,

I’m currently facing an issue with a Client Script onChange script that is not being executed at all.

The strange thing is that it is not a logic issue inside the script — the script does not seem to trigger in the first place. I already added logging statements at the very beginning of the Client Script, but nothing appears in the console/logs when I change the field value.

Has anyone experienced a similar issue or has an idea what could prevent an onChange Client Script from firing?

Things I already checked:

The Client Script is active
The field name is correct
The script type is set to onChange
I tested with simple log statements at the first line
The field value is definitely changing
Are there any less obvious reasons why an onChange Client Script would not trigger at all? For example, any configuration settings, UI policies, field types, client conditions, or other dependencies that could block it?

Any hints or troubleshooting tips would be highly appreciated. Thanks!

19 REPLIES 19

Tejas Adhalrao
Kilo Sage

hi @colin-lucwe  ,

A few things I'd suggest checking:

  • Verify that the Client Script UI Type is set to All (Desktop, Mobile, and Service Portal), or at least includes the UI where you're testing.
  • After changing the field value, tab out or move to another field, as the onChange event only fires when the field loses focus.
  • Double-check your script for any syntax errors. You can even paste it into ChatGPT or another code validator to verify the script is correct.
  • Also check the browser console for any JavaScript errors that may be preventing the script from loading.

Regards,
Tejas

If you found my solution helpful, please mark it as Helpful and Accept Solution.

Danish Bhairag2
Tera Sage

Hi @colin-lucwe ,

 

If you are ok please try this,

 

Create a new onChange script. Do not seperate the isloading & newValue function as from ur script i understand u r not doing anything. You just want your script to run on change of the variable value. So let the OOTB function which appears be as it is. 

After that put an alert("testing"), it should appear. Then paste ur actual logic of setting/removing values.

 

Thanks,

Danish Bhairagdar

It still doesn't work. The client script is only executed when the form loads. After that, it never triggers again when the field value changes.

Ehab Pilloor
Giga Sage

Hi @colin-lucwe,

 

EhabPilloor_0-1785413710477.png

Case is part of Customer Service Application. Your script is in global application. Please create another script within Customer Service Application and see if it works.

 

Please Accept this response as Solution if it assisted you with your question & Mark this response as Helpful.

 

Kind Regards,

Ehab Pilloor

I also tried creating a client script in the Customer Service Application, but I'm seeing the same behavior. The script runs on form load, but it isn't triggered when the value of the field changes.