How can I dynamically adapt the From & Reply To in email client templates ?

JérômeM
Tera Contributor

Hello Community! 

I need your help regarding email client templates. 
I need the From & Reply To to dynamically change based on some conditions. 

For example, if my contacted desk field is techsupport@xxx.com - > From & Reply To should be 'Tech Support' <techsupport@xxx.com>

How can I achieve this in the email client templates ? I 5 use cases

I tried with scripted on the from but I don't get the expected results. 

 

(function(fromAddressQuery, targetRecord) {
    util = new BEL_Util();
    from = util.getServiceDeskForClient();
	var source = "BEL UTIL CLIENT EMAIL : ";

    var regex = /<([^>]+)>$/;
    var emailAddress = [];
    emailAddress = from.match(regex);

    fromAddressQuery.addQuery('email_address', emailAddress[1]);
	gs.log(source + ' email address compiled : ' + emailAddress);

})(fromAddressQuery, targetRecord);

 

Can someone help me out ? 

Thanks

Jérôme

1 REPLY 1

Tanushree Maiti
Tera Patron

Hi @JérômeM 

 

You can update your script/script include by these kind of logic:

 

 if (current.contacted_desk == 'techsupport@xxx.com')

{

emailAddress = 'Tech Support <techsupport@xxx.com>';

}

else if (current.contacted_desk == 'billing@xxx.com')

{

emailAddress= 'Billing Department <billing@xxx.com>';

} else {

emailAddress = 'Service Desk <support@xxx.com>';

}

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti