- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 05:00 AM
Hi Experts,
Do we have any idea how can we call UI script from client script in scoped application?
please let me know syntax if anyone have.
Thanks in advance,
Amol Bavaskar
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- 2,628 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2018 02:50 AM
Hi Brad Tilton,
I have tried script loader but some how not able to use this in my code.
can you please suggest syntax for this?
Regards,
Amol bavaskar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 06:59 AM
Have you tried using GlideUIScripts or ScriptLoader? I can't remember whether either of those is available in a scoped app, though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2018 02:50 AM
Hi Brad Tilton,
I have tried script loader but some how not able to use this in my code.
can you please suggest syntax for this?
Regards,
Amol bavaskar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 05:50 AM
When you say you're not able to use it, what does that mean? Are you getting an error, and if so, what is the error? What does your code look like? If you're not getting an error what is the behavior compared to your desired behavior?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2019 01:18 AM
I am also having the same issue. I have a scoped app that is using a record producer which is accessed in the OOB SC Catalog Item widget. My record producer has a few client scripts that use the exact same code and I would like to move that code into a UI script that each client script could access. Things I have tried that do not work.
Script loader, I realize this does not work in scoped apps, but tried anyway.
g_ui_script permutations
TAKE ONE
Added to client script on load in record producer
g_ui_scripts.getUIScript('x_usdo2_travel.utils3064').then(function(script) {
script.clearFields2();
}, function() {
console.log('The script did not load');
});
Then, added to client script that needed to call the UI script function
script.clearFields2();
Also,
clearFields2();
TAKE TWO
Added to client script that needed to call UI script function
g_ui_scripts.getUIScript('x_usdo2_travel.utils3064').then(function(script) {
script.clearFields2();
}, function() {
console.log('The script did not load');
});
clearFields2();
ERROR MESSAGES
No errors in ServiceNow logs. All errors are in console log and say 'g_ui_scripts' and 'clearFields2' are not defined.
Has anyone gotten UI scripts to work in scoped apps?