I want to call a UI script from a UI action

bonsai
Mega Sage

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.");
        }
    };
})();

 

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@bonsai 

is your UI action in scoped app or global?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

is a global scope

Kalyani Jangam1
Mega Sage
Mega Sage

It's not working properly for some reason...