Prevent onChange Script Triggered by onLoad Script

Sruthi17
Kilo Sage

Hi Experts,

I have an onChange client script called "Date Validation" that runs whenever the "Extension Plan" field is changed. This script clears the Travel Start Date and Travel End Date.

I also have an onLoad client script that sets the "Extension Plan" field based on a certain condition.

The issue is: when the onLoad script sets the Extension Plan, it also triggers the onChange script, which I don’t want to happen in this case.

Is there a way to prevent the onChange script from running when the field is updated by the onLoad script?


Any suggestions to handle this scenario would be appreciated.

Thanks

 

3 REPLIES 3

Chaitanya ILCR
Kilo Patron

Hi @Sruthi17 ,

 

add this line in onchange client script like below (put it on top)

if (isLoading) {
      return;
   }

 

ChaitanyaILCR_0-1750760823220.png

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Ankur Bawiskar
Tera Patron
Tera Patron

@Sruthi17

If your onChange client script has isLoading check then it should not be triggered.

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

Syed zabiullah
Tera Expert

Hi @Sruthi17 

Can you check the "IsLoading" in onChange client script. 

If my response helped, please mark it correct.

Regards
Syed K