Get current Application scope or Update Set via Scripted API call

Andre Kosak
Tera Contributor

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?

1 ACCEPTED SOLUTION

DirkRedeker
Mega Sage

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.

find_real_file.png

 

So, fo the "System Administrator", it is currently (see screenshot below):


find_real_file.png

 

Looking into the Update Sets table, and searching for the Sys_ID, you will find the update set, that the given user currently selected:

find_real_file.png

 

Let me know, if that answers your question and mark my answer as correct and helpful, please.

 

Thanks & BR

Dirk

View solution in original post

5 REPLIES 5

DirkRedeker
Mega Sage

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.

find_real_file.png

 

So, fo the "System Administrator", it is currently (see screenshot below):


find_real_file.png

 

Looking into the Update Sets table, and searching for the Sys_ID, you will find the update set, that the given user currently selected:

find_real_file.png

 

Let me know, if that answers your question and mark my answer as correct and helpful, please.

 

Thanks & BR

Dirk