logged in user on mail template

scottjus82
Kilo Guru

Morning all.

 

I have set up a template on the incident table so when clicking the email icon the body contains the description as well as the name of the analyst the ticket is assigned to, their title and email address. I have had a request to change that so the signature element of the template is the person who is logged in clicking the email as its not always the assigned to person. could anyone advise what I change my script to? currently its a simple field mapping as per below.

 

Incident Number: ${number}

Description: ${short_description}

UPDATE

 

 

 

 

 

 

 

${assigned_to}

${assigned_to.title}

${assigned_to.email}

 

Any thoughts?

7 REPLIES 7

Kalaiarasan Pus
Giga Sage

try using something like this in body of the client template ....



<mail_script>


var uid = gs.getUserID();


var user = new GlideRecord('sys_user');


if (user.get(uid))


var userName = user.user_name;


template.print(userName);


</mail_script>



using the gliderecord (user. dot walking) you can access any field on the user record to form the signature ....


Heya,



Thanks for the response. I have added as per above to start with before adding the fields I want but when testing I get a blank email. screenshot below. I am on Eureka and I was told that a mail_script was working before they upgraded however the same script no longer works.




i did try on demo and is working for me ...



this is link for the template that i created....



https://demo001.service-now.com/sys_email_client_template.do?sys_id=0c98619c0a0a0aa100e0272f89bc062b...



is the user_name field has some value for the user you tried ????


Heya,



I have logged into your demo and pasted your script exactly (below screenshot) and its still an empty email. Any thoughts on what is blocking it?



find_real_file.png