Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Alert not firing on onChange client script

sigmachiuta
Kilo Guru

i have a onChange catalog client script that DOES change the field values so it is running but it doesn't throw the alert.

if(newValue == 'No'){

      alert(getMessage('test'));

      g_form.setValue('foo' , 'No')

      g_form.setValue('bar' , 'No')

   

      }

--or

if(newValue == 'No'){

      alert('test');

      g_form.setValue('foo' , 'No')

      g_form.setValue('bar' , 'No')

   

      }

1 ACCEPTED SOLUTION

clear cache and check to clear form data and that should resolve that part of it.


View solution in original post

39 REPLIES 39

Open the browser developr tools and see if you can find any errors in the


cosole



On Thursday, July 21, 2016, sigmachiuta <community-no-reply@servicenow.com>


huuuuuuuh!     thats weird it should be newValue... and it is in my code and blue


Uncaught ReferenceError: newvalue is not defined


oh wait thats why it didnt alert before the IF...


*** WARNING *** GlideAjax.getXMLWait - synchronous function - processor: SysMessageAjax



onChange on foo.... now it does change the values !



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


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


          return;


    }




    //Type appropriate comment here, and begin script below


    alert(getMessage('new value is ' + newValue)); // it was this new value


      if(newValue == 'No'){


      alert(getMessage('test'));


      g_form.setValue('bar' , 'No');


      }



  }


You can ignore that. It still does not alert anything!! That is weird



On Thursday, July 21, 2016, sigmachiuta <community-no-reply@servicenow.com>