onChange client script not changing field value on same form on different sections

Nishant16
Tera Expert

i have a field Amount on two sections on the same form, i have written an onChange client script to clear the 'Amount' field on change of Product field. I can see the change on one section clearing the field while on the other section the change is not happening, can someone point to me on how can i fix this?

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

if (oldValue!= newValue){
g_form.clearValue('u_amount');
}

}
3 REPLIES 3

SatyakiBose
Mega Sage

Hello @Nishant16 

It seems you are running into a known error PRB094076/KB0749081 

It is not recommened to have the same field on multiple sections on the form, and the fields might not be updated simultaneously,

The suggested workaround provided by ServiceNow is - 

Remove one of the fields from the form so that it appears one time only.

Gaurav Shirsat
Mega Sage

Hello @Nishant16 

can you please check have you make Global Field Check Box to True?

Check_Box.png

 

Mark my Response as Correct or Helpful, if you find it Appropriate.
Gaurav Shirsat : ServiceNow Community MVP 2022
https://www.linkedin.com/in/gauravshirsat/

But ServiceNow always suggests not to use the same field on a form or form section more than once.