- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2015 06:00 AM
I want/need to get the sys_id of the person impersonating, like getUserID(), but the ID of the person doing the impersonating.
Was hoping there was something like: getImpersonatingUserID(); but doesn't exist.
I tried this... var u = gs.getImpersonatingUserName().gs.getUserID();
but it did not work. Any help is appreciated, thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2015 07:30 AM
Hi Chuck,
got it.
You can basically do a simple get with the UserID of the impersonating user - that query is pretty lightweight and shouldn't affect performance too much.
Then you can simply add the sys_id of that person to your query.
You might want to verify if the impersonatingUserSysID is set/filled - if not don't even include it in the answer line (so having two answer lines - one for the case that you have the id and for the case that you don't).
var impersonatingUserName = gs.getImpersonatingUserName();
var impersonatingUserSysID = "";
var grUser = new GlideRecord("sys_user");
if(grUser.get("user_name", impersonatingUserName)) {
impersonatingUserSysID = grUser.getValue("sys_id");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2015 10:20 AM
And the other thing we did was to exclude the HR table from System Clones (System Clone - ServiceNow Wiki ) so the data would only reside in Production and could not accidentally be accessed in sub-production instances during testing. The only data that could be in that table was test data.
I just noticed in the Wiki that it states, starting with Dublin, excluded tables that are extended from Task will NOT be excluded, but I do not think that is correct. They are on Eureka, and only test data exists in the dev instance. I've requested confirmation on that from the documentation team.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2015 06:27 AM
getImpersonatingUserDisplayName() will give you the user name.
Then you can query user table to get the user object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2015 06:39 AM
Don't really want to use a query in an ACL if I don't have to. Was looking for a 1 or 2 line script if possible. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2015 06:35 AM
Hi Chuck,
In addition to Ashish suggestion, you also have gs.getImpersonatingUserName() function which will get you the user_id.
Thanks
Srinivas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2015 06:42 AM
Srinivas, that gets the user id, but not the actual sys_id of the impersonator. That is what I need. Thanks!