Add current logged user to notification/email template

ceraulo
Mega Guru

Hello!

Is it possible to add to an email body the currently logged user's name and location?

For example,

 

Dear caller.first name,

Incident Number: xxxx
Short Description: xxxx
Priority: xxxx

Thank you.

Currently logged user's name
Currently logged user's location

 

Thanks!

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Naveen makes a good point. Notifications can be triggered from different locations including Flow Designer, Workflow, Scheduled jobs, triggered from events or directly from record updates/inserts.

A universal approach would require you to evaluate all possible scenarios and ensure they are compliant so your notification script has at least the sys_id of the user who triggered the message. 

Example, if they are triggered by an event, you can include gs.eventQueue() and use the third or fourth argument to pass gs.getUserID(). However you may to be in control of all the events triggered.

View solution in original post

6 REPLIES 6

Omkar Mone
Mega Sage

Hi 

You can do it using mail script Something like this you can try :- 

<mail_script>

 

var userName =   current.caller.first_name.toString().charAt(0).toUpperCase() + current.caller.first_name.toString().slice(1);

 

template.print("Dear " + userName + "<br />");

 

</mail_script>

Naveen Sagar S1
Mega Guru

Hi,

It's possible but I can't get the exact requirement, If it is just for a mail signature then it's better not to add.

Because we normally send email notifications through events or workflows. So when you try to see the updated by field it is generally be admin or system as the events and workflows are processed in background by servicenow.

If your requirement is any email client then you can surely achieve this without any difficulty.

Chuck Tomasi
Tera Patron

Naveen makes a good point. Notifications can be triggered from different locations including Flow Designer, Workflow, Scheduled jobs, triggered from events or directly from record updates/inserts.

A universal approach would require you to evaluate all possible scenarios and ensure they are compliant so your notification script has at least the sys_id of the user who triggered the message. 

Example, if they are triggered by an event, you can include gs.eventQueue() and use the third or fourth argument to pass gs.getUserID(). However you may to be in control of all the events triggered.

Hi Chuck,

I hope I'm not too late!!! I've a requirement where in if any user be it admin or a user which has access to that table tries to export the table data, then a notification should be triggered to the security team. This email notification should contain the details of the user who has exported the table data