onchange catalog client script not firing

HugoFirst
Kilo Sage

I have an application catalog item which has an onchange catalog client script.

The problem is that the onchange catalog client script won't execute, even when I change the value in the variable on the form.

I've boiled it down to a simple alert for testing:

 

function onChange(control, oldValue, newValue, isLoading) {

  alert("huha!");

    if (isLoading || newValue == '') {

          return;

    }

    //Type appropriate comment here, and begin script below

}

 

Here's the catalog client script:

 

onchangecatalogclientscript.gif

Whenever I change the value of the variable data_center, I expect to get an alert saying "huha!".   But I get nothing.

I don't think the script is executing.   I turned on the Javascript debugger, but I'm not seeing any reference to this script.

 

Any ideas?

 

Thanks in advance for any light on this for me.   I look forward to hearing from y'all!

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Usually when I see a client script or ui policy not executing it's because there is a client script on the same table or item/variable set with an error. I would take a look at your javascript console and see if there are any errors on the page. Once a client script throws an error, none of the subsequent client scripts or ui policies will run.


View solution in original post

3 REPLIES 3

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Usually when I see a client script or ui policy not executing it's because there is a client script on the same table or item/variable set with an error. I would take a look at your javascript console and see if there are any errors on the page. Once a client script throws an error, none of the subsequent client scripts or ui policies will run.


Ding! Ding! Ding! DIng!


Thank you Brad! You are right, you are absolutely correct!


The issue was another catalog client script which took an error and prevented all other scripts from firing.


I deactivated the the other client scripts and reran.   My script ran.


Then I reactivated them one by one until I found the problem script.


The problem script was onLoad script to display the help text for several variables.


As part of my changes to the form I had removed the help text for one variable which was no longer needed.


I did attempt to debug using the Javascript console, but I'm clearly in need of some training there.



Thanks again for you advice Brad!   I think you set a new speed record for the correct answer!


Hey Brad - I was running into an odd issue on one of our catalog items.   I stumbled across your tidbit and it pointed me in the right direction.   Thanks for sharing this info!