Using shared catalog client scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello All,
Is there a 'reliable' mechanism to allow 'shared' code between / among catalog client scripts in the same catalog item?
That is, a client catalog script would load with the intent of being able to be called by another client catalog script in the same catalog item. Presently using Yokohama (patch 10).
Thanks in advance,
John Spencer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello @John Spencer
You could consider using a UI Script to store the shared functions and then call those functions from your Catalog Client Scripts. This is a reliable way to reuse client-side code across multiple scripts and helps avoid duplicating logic.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
there is no available OOTB mechanism to control shared code between catalog client scripts.
You need to handle this with your development experience and customer requirement and try to avoid conflicting scripts.
Try to keep script in single onLoad always and you can write onChange script on variable based on requirement.
💡 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 || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi ,
In ServiceNow, a UI Script is a reusable block of client-side JavaScript code, similar to how a Script Include works for server-side code. They are used to promote code reusability and maintainability by centralizing common client-side functions like Client Scripts and Catalog Client Scripts.
Ref: https://www.servicenow.com/docs/r/api-reference/scripts/c_UIScripts.html

