Email Client Template - Reply To

ceraulo
Mega Guru

Hello!

In the notification email script, we can set the 'setFrom' and 'setReplyTo' using the following script:

 if (current.assignment_group == 'ServiceNow Experts')) {
        email.setFrom('ServiceNow Experts <servicenowexperts@email.com>');
        email.setReplyTo('ServiceNow Experts <itservicedesk@email.com>');
    } 
	
	else {
        email.setFrom('IT Service Desk <itservicedesk@email.com>');
        email.setReplyTo('IT Service Desk <itservicedesk@email.com>');
}

But when using the email client, the configuration is different. We need to create an Email Client From Address for ServiceNow Experts and an Email Client Template. 

In the Email Client Template, the Sender Configuration > Script must be updated. I was able to do this using the below script.

var group = targetRecord.getValue('assignment_group');
	
	if (group == 'ServiceNow Experts')
        fromAddressQuery.addQuery('email_address', 'servicenowexperts@email.com');
    else 
        fromAddressQuery.addQuery('email_address', 'itservicedesk@email.com>');

The above script only covers the email.setFrom in the notification email script.
How to do for email.setReplyTo?

Please help!

Thank you.

1 ACCEPTED SOLUTION

Hi,

To set the dynamic ReplyTo, you need to create email client template and script include. In email client template field just call it in 'Reply to' field.

getReplyToEmailId: function(){
		var replyToEmail = '';
		if (current.assignment_group== 'u_ap_invoices'){
			replyToEmail = 'testExample1@test.com';

		}else{
			replyToEmail = 'testExample2@test.com';
			
		}
		return replyToEmail;
	},

Call script include:

javascript:new global.GetReplyToEmailId().getReplyToEmailId();

 

OR just add below conditional script in ReplyTo field - Email client template.

javascript: if (current.assignment_group == 'group_sys_id'){
testExample1@test.com
}else{
testExample2@test.com
}
	

For reference: Email client template ServiceNow

 

Regards,

Sagar Pagar

The world works with ServiceNow

View solution in original post

3 REPLIES 3

Anil Lande
Kilo Patron

Hi,

There is OOB field 'Reply to' on Email Client Template table, you can see it in List View.

Edit that field in List view or add that on form view and make set reply to as per your requirement.

find_real_file.png

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

@Anil Lande 

Apologies for the late feedback. I was caught up with other client projects.

I have added the Reply to field to the form. However, I want to set different 'Reply to' depending on the Assignment group. 

In the Email Notification script, using the below code will work. 

email.setReplyTo('ServiceNow Basic Users <snbasicusers@email.com>');

Is there a way to use this in the 'Reply to' field of the Email Client Template?

Please help!

Thank you.

Hi,

To set the dynamic ReplyTo, you need to create email client template and script include. In email client template field just call it in 'Reply to' field.

getReplyToEmailId: function(){
		var replyToEmail = '';
		if (current.assignment_group== 'u_ap_invoices'){
			replyToEmail = 'testExample1@test.com';

		}else{
			replyToEmail = 'testExample2@test.com';
			
		}
		return replyToEmail;
	},

Call script include:

javascript:new global.GetReplyToEmailId().getReplyToEmailId();

 

OR just add below conditional script in ReplyTo field - Email client template.

javascript: if (current.assignment_group == 'group_sys_id'){
testExample1@test.com
}else{
testExample2@test.com
}
	

For reference: Email client template ServiceNow

 

Regards,

Sagar Pagar

The world works with ServiceNow