How can you get the recent impersonation list for a user?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2017 02:39 PM
I'm recreating the impersonate modal in a portal page menu and have it nearly finished. I still need the list of recent impersonations that the user has recently attempted. Is there any way to access this data?
Thanks!
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2017 02:42 PM
I see you may have duplicated your post to the Community. See the answers in this thread:
How do you get the recent list of Impersonations attempts for a user?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2017 03:22 AM
Hi Heather,
I found below API which is being used for impersonate but so far you need to pass username and password for authentication.
I am looking for a way to avoid sending username and password if the user is logged.
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://INSTANCE_NAME.service-now.com/api/now/ui/impersonate/recent');
request.setHttpMethod('GET');
//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'admin';
var password = 'admin';
request.setBasicAuth(user,password);
request.setRequestHeader("Accept","application/json");
var response = request.execute();
gs.log(response.getBody());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2017 04:18 AM
Chirag, there is a duplicate thread as noted above. The following works too
The list of recent impersonations is stored in a user preference record named recent.impersonations. You can use the following script to get the list for the current logged in user:
gs.getUser().getPreference("recent.impersonations")
This should output a string separated by commas.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2017 04:33 AM
If you want to go this route of using the REST API, you can invoke it client side and pass the user session token for authentication. See this thread for examples.
Is it possible to call a scripted REST API from a client script?
Please mark any post helpful or the correct answer to your questions so others can benefit.