I want to call a UI script from a UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2023 10:45 PM
I want to call a UI script from a UI action with the script below.
The code content is based on product documentation and references.
However, when I run this UI action, I only get a "test" popup.
How can I use UI scripts in UI actions?
UI action
function test_test() {
alert("test");
g_ui_scripts.getUIScript('myUIScript').then(function(script) {
script.myUIScriptMethod();
}, function() {
alert('The script did not load');
});
alert("test1");
}
UI script
・UI type: Desktop
・Global: True
(function() {
return {
myUIScriptMethod: function() {
alert("This is an alert.");
}
};
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2023 11:55 PM
is your UI action in scoped app or global?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 01:05 AM
is a global scope
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 12:07 AM
Hi @bonsai
Please refer this KB article
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0791206
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 01:14 AM
It's not working properly for some reason...