Facing issue with on change client script in servicenow Yokohama

rk51
Giga Contributor

After the Yokohama upgrade, the “on change” client script pop-ups are appearing twice—first when the field changes and again when saving the form. Has anyone else encountered this issue after the upgrade?

6 REPLIES 6

Hemanth M1
Giga Sage
Giga Sage

Hi @rk51 , 

 

Not really. May I know what your onChange script does?

 

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Ankur Bawiskar
Tera Patron
Tera Patron

@rk51 

Should not happen

share your complete script along with client script config screenshots

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var main= g_form.getValue('main_acc');
    if ((main== 'M') && (newValue != '')) {
        if (((newValue == 'All') || (newValue == 'IN')) && ((oldValue == 'All') || (oldValue == 'IN'))) 
		{
 alert("Message1");
        }
		else if((newValue == 'All') || (newValue == 'IN')||(g_scratchpad.man == 'All') || (g_scratchpad.man == 'IN'))
		{
alert("Message 2");
       }
	
    }
}

//Scractchpad code:

g_scratchpad.man = current.fieldname;

@rk51 

your onchange won't run after form is saved unless some onload script is changing the field on which onChange runs

what debugging did you perform?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader