Calling UI script from client script in scoped application

IamAmolB
Tera Guru

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

1 ACCEPTED SOLUTION

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

View solution in original post

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Have you tried using GlideUIScripts or ScriptLoader? I can't remember whether either of those is available in a scoped app, though.

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

Brad Tilton
ServiceNow Employee
ServiceNow Employee

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?

Community Alums
Not applicable

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?