- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2022 02:30 AM
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.
Solved! Go to Solution.
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 10:51 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2022 06:14 AM
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.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 10:30 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 10:51 PM
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