- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 05:53 AM
Hi Everyone,
I have created a UI Script in Custom Scope 'A' and I want to call this script into UI Action which is present in custom scope B.
Is it Possible for me to call cross scope UI script into UI Action.
UI Script:
functionsUIscriptHelpers();
function functionsUIscriptHelpers() {
function helper1() {
alert("TEST helper1 FUNC")
}
functionsUIscriptHelpers.functionsUIscriptHelpers = helper1;
}
UI Action:
function onClickOfUIAction() {
functionsUIscriptHelpers.helper1();
}
I cannot see the Alert message. Please guide how can I call cross scope UI Script into UI Action. And I want to know, can I send some variables also into this UI script.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 09:05 AM
It works, you should be able to call UI script created in scope A from any outside scope
UI Script: Created in scope "01/23"
Called that UI Script from Client script in other scope "16Jan 001"
Output: It called that function and gave alert when onload form was opened for My Table present in scope "16Jan 001"
I hope I have answered your question.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 06:08 AM
any reason not to create that UI script in the same scope as that of client script?
check this link
[SOLVED] How to call scoped UI script from catalog client script ?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 06:37 AM
Yes, we have a reason to create UI script in different scope. So, we will put UI script in Scope 'A' and we call this script into multiple scopes. Like UI action in scope 'B' will call this UI Script in scope 'A' and UI action in scope 'C' will call this UI script in scope 'A'. Basically, multiple UI action in different scopes will call this common UI Script.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 06:58 AM
did you check the link I shared?
It talks about using UI script in scoped app, see the same syntax works when it calls from other scope
any cross scope issue comes or not?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 07:24 AM
Hi @Ankur Bawiskar,
I cannot see Script Loader working. In console I see '1'and '2'. I am not sure whether UI action is even calling UI Script.
UI Script:
/* eslint-disable no-mixed-spaces-and-tabs */
var x_fmc_ibfs = x_fmc_ibfs || {};
x_fmc_ibfs.MyScriptDesktop = (function() {
"use strict";
return {
myUtilityFunction: function(myParameter1, myParameter2) {
console.warn("Hello World! myParameter1: " + myParameter1 + ". myParameter2: " + myParameter2);
return myParameter1 + myParameter2;
},
type: "MyScriptDesktop"
};
})();
UI Action:
function PopupITSM() {
function myClientSide() {
var myResult = MyScriptDesktop.myUtilityFunction("P1", "P2");
alert("myResult: " + myResult);
}
console.warn("1");
ScriptLoader.getScripts("MyScriptDesktop.jsdbx",myClientSide);
console.warn("2");
return;
}