
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2020 02:52 PM
I am creating new accounts via workflow. Only Admin can create accounts per business rules to create the account code and path.
So in my workflow I am impersonating admin before creating the account.
However I need to end the impersonation in the script because it logs the user off.
//Only admin can create accounts, must impersonate admin
var impUser = new GlideImpersonate();
impUser.impersonate('6816f79cc0a8016401c5a33be04be441');
//Create Account
How do I stop impersonating?
Thanks,
Stacy
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2020 04:09 PM
If I am following you correctly then you have impersonated an admin user in the workflow script and now you want to impersonate back to logged in user? I believe you need to re impersonate the logged in user. Try something like this
var currentUser = gs.getUserID();
var impUser = new GlideImpersonate();
impUser.impersonate('6816f79cc0a8016401c5a33be04be441');
impUser.impersonate(currentUser);
Thanks & Regards,
Sharjeel
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2020 04:00 PM
So oddly I can have this same approver (without the admin role) create an account in the account table without the error. So I don't know why I have the problem in the workflow if they don't have the admin role.
I opened a ticket with HI and will let y'all know what they say.
thanks,
Stacy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 12:50 PM
Hi,
This is an old thread but I am facing similar situation. Did you get any answer from Hi?
Thanks,
DP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2020 04:09 PM
If I am following you correctly then you have impersonated an admin user in the workflow script and now you want to impersonate back to logged in user? I believe you need to re impersonate the logged in user. Try something like this
var currentUser = gs.getUserID();
var impUser = new GlideImpersonate();
impUser.impersonate('6816f79cc0a8016401c5a33be04be441');
impUser.impersonate(currentUser);
Thanks & Regards,
Sharjeel
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2020 04:16 PM
That's what I replied earlier. From the description of the method, it doesn't seem like the method is putting userSysId into a stack as it's done from the GUI.
That is, the method is just switching users and there's no "end impersonation" when calling from a method.