Email Client Template 'From' Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 12:57 PM
Hello,
We are using the Reply, Reply All and Forward buttons on emails sent and received in the activity for incidents.
We are trying to update the 'From' email address if the assignment group is a specific group.
For example, if we were sending a reply from and incident in the Service Desk assignment group we would want it to deliver to the user as 'ServiceDesk@company.com' but if we were sending from an incident in the Infrastructure assignment group, then we would want it to come from 'Infrastructure@company.com'.
I have found where the templates are managed from, Email Client Templates. We have tried updating the mail script and the Sender Configuration > From Generation Type > Script, however had no joy. I'd imagine its something we are doing wrong with the script.
I hope this makes sense.
Thanks,
Adam
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 01:09 PM
Hello,
Possibly.
Unfortunately, you didn't provide what you have so far so we can't really help?
Please mark reply as Helpful, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 01:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 01:33 PM
Hi,
Could you show the full script?
From what you showed , Id try the script part like this
email.setFrom(current.Service Desk);
//or like this since we dont know how rest of your script looks like.
email.setFrom("Service Desk");
But is "Service Desk" a field on the form or just a string?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 01:37 PM
Hello,
You mentioned you don't have the script for some reason.
Anyways, you can review the appropriate documentation for setting the from via: https://docs.servicenow.com/bundle/quebec-servicenow-platform/page/script/server-scripting/reference...
So in your mail script, you'd need to evaluate the current assignment group and then set the from accordingly, as in:
if (current.getValue('assignment_group') == 'sys_id_of_service_group') {
email.setFrom("Email@Example.com);
} else if (current.getValue('assignment_group') == 'sys_id_of_infrastructure_group') {
email.setFrom("Otheremail@example.com");
}
Then call that mail script in your template such as: ${mail_script:name_of_script}
You would place the above in the Body HTML field of the email client template.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!