email notification for impersonate User
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 08:30 AM
Hi
The management would like to get an email anytime admin impersonate a user. I got the email notification working but I am not able to get who is the user name in the body of an email? help please?
I found this article helpful but the script sends an email to the user which I don't want.
I want the user name in the body of an email who the admin impersonated.
https://community.servicenow.com/community?id=community_question&sys_id=b0a38b65dbd8dbc01dcaf3231f961967&view_source=searchResult
Thank you
- Labels:
-
Instance Configuration

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 08:40 AM
By "management" is this the users manager or a certain group? If the latter, you would specify the group as the recipient on the "who to send to" section of the notification record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 08:46 AM
hi
I already have the email notification working to a group (management).
I want to include who the admin impersonated.
For example, if I impersonated Mary Jo, the body of the notification should include Mary Jo name.
thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 08:43 AM
So what have you done so far, did you create the notification, you can hard code the recipients in the notification that you would have created and in then Whom to send section you can hardcode the user, group or email to whom you want to send the notification
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 08:51 AM
You will want to add the following mail script to your notification:
<mail_script>
var userName = event.parm2;
var gr = new GlideRecord('sys_user');
gr.addQuery('user_name', userName);
gr.query();
if (gr.next()) {
template.print('User impersonated: ' + gr.name + ' (' + userName + ')');
}
</mail_script>