2 client scripts loading differently in different instances
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi All,
We have 2 onChange client scripts running on same field. In Dev, cs 1 is loading first and cs2 is loading second which is setting expected behaviour.
In QA, cs 2 is running first and cs1 is running second which is creating discrepancy. in Both instances, no order is mentioned for the client scripts and no code differences also(checked in diff checker as well).
So, I have tried to change the order of client scripts in QA, it is then setting expected behaviour. But i wanted to know if this behaviour is kind of expected internally in ServiceNow?
If not, kindly help me with your insights and suggestions.
Note : i don't see any other configuration that kind of causing this behaviour.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
order field on Client script is not taken into account
The behavior will be inconsistent as system loads client scripts on it's own
So better to merge both the onLoad logic in single client script
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited 2 hours ago
Hi @klavan32
If you don't explicitly define an Order value, the execution sequence becomes unpredictable and can vary.
As per servicenow documentation - Control the order of execution for your client scripts using the Order field. To avoid having two or more client scripts run concurrently and then conflict, you can add an order for the scripts to run in.
Also refer below client script design and processing documentation. If you found any deviations create Hi support case.
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks!
Krishnamohan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
43m ago
First of all, I can't think of reason having two client script on same field. So its better/recommended/best practice to have only one script.
and 2nd, if you don't have order defined on your script, it can cause issue as all client script are getting loaded in user's browser when form is opened and runs when conditions are met. As you dont have order mentioned it is unpredictable which will run first.
Regards,
Siddhesh Gawade