- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2018 01:48 AM
Hi there,
the ServiceNow user interface has a picker in the top bar where the active scope can be selected.
Is there any way to get that current active scope in a script (server or client side)? It doesn't matter if I get the name or the sys_id of the scope, either one would be ok for me.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2018 08:54 AM
I may have found a better solution than the accepted one.
gs.getCurrentApplicationId();
This returns the 'sys_id' of the current the application the user is in.
Use this sys_id to GlideRecord into 'sys_apps' and you'll get the name of the app.
var currentApp = gs.getCurrentApplicationId();
var gr = new GlideRecord('sys_app');
gr.get(currentApp);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2018 01:52 AM
Hi,
I think you are looking for this method.
gs.getCurrentScopeName()
Please mark it correct/helpful based on the response.
Thanks
Gaurav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 03:58 PM
I want to change the scope in the middle of the script and come back to original scope after a certain action is performed. Can this all be done in scripting? Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 05:01 PM
Hi @amol_joshi ,
You can use Script Include for the same where you can define the script in the scope where you want to perform action and return the value. Changing scope I can say isn't a best practice/recommended.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2018 02:09 AM
Hi,
Try this code,
var getCurrentScope=gs.getCurrentScopeName();
gs.print(getCurrentScope);
Thanks,
Tripti.