OnChange Client Script Executing after onLoad in workspace

Meet Mewada
Tera Expert

Hi everyone,

 

I’ve created my first OnLoad client script for the Incident table that sets the Assignment Group to a specific value. I also have an OnChange client script tied to the Assignment Group field.

 

In Workspace, I’ve noticed that my OnChange script executes immediately after OnLoad, even though I’ve included the usual check: if (isLoading) return true;

 

From my understanding, this should prevent the OnChange script from firing during the initial load. However, in Workspace it seems to behave differently. FYI, this works very well in native UI.

 

Has anyone else experienced this? Is there a known difference in how Workspace handles OnLoad and OnChange client scripts compared to the classic UI? Any insights or best practices to ensure OnChange doesn’t trigger right after OnLoad would be greatly appreciated.

 

Thanks in advance!

3 REPLIES 3

Ankur Bawiskar
Tera Patron

@Meet Mewada 

that onChange should not work when form loads if isLoading return true is mentioned

Did you try adding alert within isLoading?

Did you try deactivating it and see?

Did you clear instance cache using cache.do and then logout and login again?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Meet Mewada
Tera Expert

Yes! Indeed i tried to debug using Alerts, cleared Instance Cache but this still persist.

 

 

Hi @Meet Mewada 

Same is happening to me as well, the isLoading not working in the workspace but working as expected in the Native UI.
I added logs in both inside isLoading and outside isLoading, both are triggering on the time of form load. You can raise a Hi ticket for this issue. For workaround - Deactivate your onLoad script and set assignment group through display BR.