Impersonating a user in server script and impersonating back to the original user

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 01:10 AM
Hello, I need help with impersonating a user in server script and impersonating back to the original user. Whats the best way to accomplish this ?
I have tried GlideImpersonate. Here is the code
gs.addInfoMessage(gs.getUserDisplayName());
var y = new GlideImpersonate().impersonate('a8f98bb0eb32010045e1a5115206fe3a');
gs.addInfoMessage(gs.getUserDisplayName());
new GlideImpersonate().impersonate(y);
gs.addInfoMessage(gs.getUserDisplayName());
The output i get when i try to execute in background scripts is
But, when i try to do the same in script include, I get the following output
Here, the script is able to impersonate to Abraham Lincoln, but isn’t able to impersonate back to System Administrator.
Can you please tell me where am i going wrong ?
Labels:
- Labels:
-
Scripting and Coding
5 REPLIES 5

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 01:42 AM
Hi
So yes it'll impersonate to abraham only....try passing admin sys_id there.