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.

Client Script newValue not working

servicetrout
Tera Expert

The following client script on a service form, which is active, Global, not Inherited, of type OnChange, Table = correct table, and Field Name = correct field name and the form field currently has the following value "20%"   shows the following in the alert ... regardless of what a user enters into the field, such as "30%", "15%", "5%", 10,15,30.

newValue: 20%  Old: 20%       (everytime).

Any ideas on what might be going on would be greatly appreciated. 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading ) {
return;
}
   alert ("newValue: " + newValue + " Old: " + oldValue);      //  Always displays the same value that is in the field?!

}

Thank you in advance. 

- G

 

In fact if I change it to this: 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading ) {
return;
}
alert ("newValue: " + newValue + " Old: " + oldValue); // Totally not working !!
var inVal = g_form.getValue('u_pdepttax');
alert ("inVal: " + inVal);

}

 

The second alert displays the original value and not the one I enter into the field on the form, as well. 

Thus, second alert displays "20%" when 30 is entered into the field?  Odd.  Everything else on the form works as expected - FWIW.

 

 

 

 

8 REPLIES 8

ggg
Giga Guru

what data type is the field in question?

ggg
Giga Guru

works fine with a string.

servicetrout
Tera Expert

Field type is string.  No, it is not working as expected.

 

i have a field on my record, 'name', type string.

when i open the record value is 20%.

i change it to 30%.

the alert ("newValue: " + newValue + " Old: " + oldValue) displays the value as expected.

newValue: 30%  Old: 20%