- 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 03:00 AM
Thanks for the suggestions.
The method gs.getCurrentScope() always returns the scope in which the script include is defined. I need to get the scope that the user has currently selected in the scope picker.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2018 03:42 AM
Then, I am afraid there is no easy way to achieve it.
Currently, I couldn't find the table which stores all the application with the current status but there is an API which can return you the current scope which user has selected.
https://instancename.service-now.com/api/now/ui/concoursepicker/application
Try hitting this one and get the current scope in xml/json format.
You can then parse the response to see the current scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2018 01:57 AM
Thanks Gaurav,
I've been digging around a little bit inside that REST API story. It's seems that the required authentication setup is out of scope for the app we're building.
Anyway it's good to know how this could be done in case we absolutely must do it 🙂
- 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
12-07-2018 12:33 AM
In fact you did!
Thanks for your solution - it does what I need and is easy to use.