- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2017 06:43 AM
I have an onBefore business rule that limits user query results based on which domain a user exists in. This rule interferes with trying to impersonate back to myself from a non-admin user (causes me to have to logout and log back in as myself).
Is there a condition I can write that will ignore this business rule if trying to impersonate?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2017 07:21 AM
The working solution I used was posted on here but must have been removed.
I added !gs.getImpersonatingUserName() to the condition line in my Business Rule script and am now able to successfully impersonate back to myself from a non-admin user.
Thanks all!
P.S. That gs.getSession().isImpersonating() looks like it will come in handy down the line too so thanks for that as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2017 06:45 AM
Hi Nathan,
Yes, there is an isImpersonating() method available in gs.getSession().
var isImpersonator = gs.getSession().isImpersonating();
gs.info(isImpersonator);
https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_SGSSN-isImpersonating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2020 06:13 PM
Hi Tomasi,
I wonder if there is a way to get the sys_id of the user before the impersonate, brcause the sys_id i got using the gs.getUserID() is the sys_id of the user after the impersonate user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2017 06:46 AM
Hi Nathan,
Are you saying that you want this business rule not to run when somebody impersonates the user.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2020 06:13 PM
Hi Bawiskar,
I wonder if there is a way to get the sys_id of the user before the impersonate, brcause the sys_id i got using the gs.getUserID() is the sys_id of the user after the impersonate user.