email notification for impersonate User

Navneet3
Tera Expert

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 

6 REPLIES 6

Kieran Anson
Kilo Patron

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.

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

 

Aman Kumar S
Kilo Patron

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

Best Regards
Aman Kumar

Julio Valdez JR
Giga Contributor

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>