Dynamic reply-to on email notification

Not applicable

We have a business rule that sends email to a group of people, and we'd like to set 'reply-to' to the address of whoever triggered the business rule that sent the message.

Apparently, service-now only allows that filed to be hard-coded. I've tested setting this to an email address (works), to the table field with the user's address (u_reply_to - doesn't work), and to the table field using ${u_reply_to} (didn't work either). Any ideas?

2 REPLIES 2

jmarlow
Kilo Contributor

Any update on this miguel?


Not applicable

Using the main 'Email Notification' form will only allow, as I noted in the original post, to set 'Reply To' to a static (hard-coded) address. The solution is creating an email template, where 'Reply To' can be set using a variable.

I was creating a record producer in our SNC page that would let our users create and send an email. These users wanted the email to be sent as if it were from the personal account (i.e., with their name and email on 'From' and 'Reply To') so people receiving the email could reply to them directly.


//this code will get the 'parm1' value that was sent when the event was triggered
var train_id = new String();

var get_parm = new GlideRecord('sysevent');
get_parm.addQuery('name', 'email.training_users');
get_parm.addQuery('instance', current.sys_id);
get_parm.orderByDesc('sys_created_on');
get_parm.query();
if(get_parm.next()){
train_id = get_parm.parm1;
}

//parm1 was the sys_id of the record inserted to the u_training_email table, which has all the info needed for the email
var email_info = new GlideRecord('u_training_email');
email_info.addQuery('sys_id', train_id);
email_info.query();
if(email_info.next()){
//email is the object that represents the actual email notification
//using setFrom and setReplyTo methods to their appropriate values according to the u_training_email record
email.setFrom(email_info.u_from + " <" + email_info.u_reply_to + ">");
email.setReplyTo(email_info.u_reply_to);
//to set the body of the email, use template.print
template.print(email_info.u_body);
email.setSubject(email_info.u_subject);
}