- 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-30-2023 09:40 PM - edited 04-30-2023 09:41 PM
/* Gets the currently Open Update Set */
UpdateSetUtil.prototype._getCurrentUpdateSet = function() {
var functionName = "_getCurrentUpdateSet";
var sid = new GlideUpdateSet().get();
this.gsLog.logDebug(functionName + ": sid = " + sid);
var currentUpdateSet = new GlideRecord("sys_update_set");
currentUpdateSet.get(sid);
return currentUpdateSet;
};
/* Gets the name of the currently Open Scope */
UpdateSetUtil.prototype._getApplicationName = function() {
var functionName = "_getApplicationName";
var currentUpdateSet = this._getCurrentUpdateSet();
var app = currentUpdateSet.getDisplayValue(application);
return app;
};