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

servicetrout
Tera Expert

Tried watching the field with everything checked.  Nothing happens when the value changes, which is to say the watcher reports no activity. 

Tried deleting the client script, then recreating it.  Same result. 

stumped on this one.

Make this change and check once

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

Mark the comment as a correct answer and also helpful once worked.

servicetrout
Tera Expert

Same result.

Are you saying newValue is always showing the oldValue and not the new Value?

And can you check in the form if there are any 2 fields having the same name. 

Also, Instead of alert, can you try g_form.addInfoMessage and check once.

Also clear the server caches once by typing cache.do