How to call UI Scripts from Client Scripts

Mi4
Tera Expert

Hi.,

I want to call a global UI Script from a scoped application.

But I keep getting the following error.

What's wrong?

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var segmenter = new global.TinySegmenter(); }

 

Thanks in advance,

1 ACCEPTED SOLUTION

Megha Padale
Giga Guru

Hi,

You can use ScriptLoader 

ScriptLoader.getScripts(['scripts/get_wsdl_url.js'], function() {  });

https://developer.servicenow.com/dev.do#!/reference/api/madrid/client/c_ScriptLoaderAPI

You access the ScriptLoader methods by using the global object ScriptLoader.
 
 

If my answer helped you in any way, mark answer as helpful and correct.

Thanks and regards,

Megha.

View solution in original post

14 REPLIES 14

Nikhil Bahurup1
Tera Expert

Hi,

Below is the syntax to call UI script from client script.

function onLoad() {
    //Call the UI script directly If the UI Type is Mobile / Service Portal, for example:
    //g_ui_scripts['myUIScript'];

    //Use the method if the UI Type is All or Desktop
    g_ui_scripts.getUIScript('myUIScript').then(function(script) {
        script.myUIScriptMethod();
    }, function() {
        console.log('The script did not load');
    });
}

Hi,

Thank you for your advice.

But and error..

 

Regards,

Megha Padale
Giga Guru

Hi,

You can use ScriptLoader 

ScriptLoader.getScripts(['scripts/get_wsdl_url.js'], function() {  });

https://developer.servicenow.com/dev.do#!/reference/api/madrid/client/c_ScriptLoaderAPI

You access the ScriptLoader methods by using the global object ScriptLoader.
 
 

If my answer helped you in any way, mark answer as helpful and correct.

Thanks and regards,

Megha.

Hi,

I'm trying

 

Regards,

Hi,

please try this;

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var segmenter = TinySegmenter();

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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