How to access gs.getCurrentScopeName() from client side UI Actions?

xMTinkerer
Giga Expert

I must say I like this "gs.getCurrentScopeName()" function as it means I don't have to hardcode the scope name in all my scripts. However, the "gs" object is not accessible in UI Actions with the client box checked. Any ideas on how to access this value? I suppose using g_scratchpad would work, but checking if there are any "native" avenues rather than having to create a server side record just to set this value.

7 REPLIES 7

Ah, I may not have been clear.


My UI Action is on the Incident form and needs to display a dialog from a different scope. So g_form gives me the scope of the Incident record, not the target dialog.


When I used this code I had to add "this" to the call to g_scratchpad in my UI Page (GlideDialogWindow launched from a UI Action)



var qd_ip = this.g_scratchpad.qd_ip;


jQuery('#srcip').val(this.g_scratchpad.qd_ip);


BobbyNow
ServiceNow Employee
ServiceNow Employee

gs.getCurrentScopeName() is going to give you the the scope you currently have selected via the application picker not the scope of the form you are on. Is this what you are after?




If you are after the scope of the form you are currently on you can use g_form.scope