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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I could see you are using new operator

you can directly call the function within UI script

Also did you set UI Type as ALL for your client script?

please share code

Thanks
Ankur

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

Hi,

Thank you for your comment.

UI Script works on Global.

 

Regards,

Hi,

can you call it like 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

Hi,

error..

Regards,

Hi,

check if these link helps

https://community.servicenow.com/community?id=community_question&sys_id=278293a1db101fc01dcaf3231f96...

https://community.servicenow.com/community?id=community_question&sys_id=a9fe1462db52ab807d3e02d5ca96...

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

if not then

Looks like creating reusable UI Scripts in a scope will not work. I created a global UI script in the Global scope so that it can be used in a client script of custom scoped application.

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