- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2019 09:07 AM
Hello Community,
I am trying to get the current application scope of a user via Scripted API call, but the platform behaves unexpected. Here is my Scripted REST resource:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
//var session = gs.getSession();
//var appID = session.getCurrentApplicationId(); // Illegal call
var appID1 = gs.getCallerScopeName(); // always "rhino.global"
var appID2 = gs.getCurrentScopeName(); // always "rhino.global"
var appID3 = gs.getCurrentApplicationId(); // always "global"
var appID4 = new GlideUpdateSet().get(); // Always "066f396ab96013006517ce7df7ee46b2"
gs.info('appID1 '+appID1+'\n appID2 ' + appID2 + '\n appID3 '+appID3 + '\n appID4 '+appID4);
// Return current scope of user session
response.setBody({'response':'Application ID should be here'});
response.setStatus(200);
})(request, response);
In comments you see the value that variable gets every time, disregarding of current Application scope selected.
How do I test it:
I am logged in with my "admin" user and switching the application scope from Global to any other. Then sending a request to the Scripted API endpoint authentificating myself with the same user. I assuming to get the current Application ID (or name) of my user session. But the methods listed above returning always same values.
Getting the sys_id of current Update Set would also help me, but new GlideUpdateSet().get() returning the same value all the time (sys_id of Default Update Set).
Any ideas?
Solved! Go to Solution.
- Labels:
-
Best Practices

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2019 12:11 AM
Hi
if you want to find out, which is the current update set of any given user, you can look into the "User Preferences" [sys_user_preference] table. See screenshot below:
The "Value" column contains the "sys_id" of the Update set, which is the current setting of the given user.
So, fo the "System Administrator", it is currently (see screenshot below):
Looking into the Update Sets table, and searching for the Sys_ID, you will find the update set, that the given user currently selected:
Let me know, if that answers your question and mark my answer as correct and helpful, please.
Thanks & BR
Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2019 10:17 AM
Hi,
In which scope the scripted rest api is created?
I have one scripted rest api in custom scoped app and when I test it is giving below results
appID1 x_30520_ank
appID2 x_30520_ank
appID3 global
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2019 10:32 AM
Hi,
The scripted api has been created in Global.
My intension is to get the Application Scope of current user session, not the scope of the scripted rest api...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2019 10:51 PM
Hi Andre,
User record doesn't belong to any scope i.e. you cannot have scope defined for sys_user table as the application field is not present on sys_user table
So any user who is present in sys_user table is always created in global scope
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 09:10 AM
Hi Ankur,
that is not what Andre was asking though.
It's about the user session, not the sys_user itself.