Email Client Template FROM (who clicked the icon)

cokemachine
Mega Contributor

I'm trying to figure out how to create an Incident-related Email Client Template which, when used via the email icon/envelope, will depict the name (or userid) of the person who sent the email, and retain that information in the subsequent Activity Detail.     I've found a solution here on the community where someone put ${sys_created_by} in the subject line, but that simply presents the userid of the person who created the Incident ticket, and not the person who clicked the email icon/envelope to send the email.

I've also found that I can put the following in the From field of the Email Client Template:

javascript:gs.getUserDisplayName()

Afterward, when I click the email icon/envelope, it will display my name in that field, as expected.

However when I put that same javascript in the CC or BCC fields, it does not show anything at all (other than the default "Add Address").   I don't understand why that same javascript would not work in those two fields.

Ideally I'd like to leave the default From value alone and not use the javascript in that field (so the name and address of our Servicenow system appears), so when the recipient replies to the email, it will update the applicable incident ticket.

Ideally I'd like to have the name of the person who clicked the email icon/envelope appear in the CC or BCC fields, or in the Subject line behind text such as "Email from xxxxx re: ${number}, or in the body of the email itself via mail script, for example.

Any ideas how I'd accomplish this?

1 ACCEPTED SOLUTION

Sorry for being not clear enough. But this is how I was thinking to get it together.



With Client template you can set up how the email client will look like when you press the "email button". out the box you can put in field names in for example bcc, set how the subject should be default etc.



I hadn't tested this before, so I thought that you had to create a mail script with the email.addAddress('cc',gs.getUser().email); and then call the mail script from the template. But I tested some and I don't need a mail script. you can do it all in the template like this:



1. Create a template for the specific table. Here I create one for incident. In the example I also put the field caller_id as a CC just to show how to use that functionality. Then I have written a javascript code to fetch the logged in users mailaddress and put that one in the bcc.



mailclient 2.PNG



And here is when I clicked on the mail icon as admin



mailclient 3.PNG




Hope this helps you out. If you got any other questions or I got you wrong.



//Göran


View solution in original post

9 REPLIES 9

Sorry if I'm not catching on here, or realizing how to transfer concepts to another area, but those links seem to relate to normal email notifications or email templates or mail scripts, not the use of the email icon/envelope within an Incident ticket for example, where one can create their own Email Client Template.   The final link you provided above focuses on the "recipient" of the email, whereas I need to capture the name, email address, or userid of the person who clicked on the email icon/envelope.


Sorry for being not clear enough. But this is how I was thinking to get it together.



With Client template you can set up how the email client will look like when you press the "email button". out the box you can put in field names in for example bcc, set how the subject should be default etc.



I hadn't tested this before, so I thought that you had to create a mail script with the email.addAddress('cc',gs.getUser().email); and then call the mail script from the template. But I tested some and I don't need a mail script. you can do it all in the template like this:



1. Create a template for the specific table. Here I create one for incident. In the example I also put the field caller_id as a CC just to show how to use that functionality. Then I have written a javascript code to fetch the logged in users mailaddress and put that one in the bcc.



mailclient 2.PNG



And here is when I clicked on the mail icon as admin



mailclient 3.PNG




Hope this helps you out. If you got any other questions or I got you wrong.



//Göran


Thanks Goran!   That works well for me (an inexperienced admin).   We'll see if that solution is acceptable to my superiors .



Interesting, if I put the javascript in the Bcc field, that doesn't show up in the Activity tab after the email is sent, so it appears I'll have to keep it at the Cc level.