Email Client Template 'From' Script

Adam Ginger1
Tera Contributor

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

6 REPLIES 6

Allen Andreas
Administrator
Administrator

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!

Hi Allen, Thanks for the quick reply. I’ll be honest I haven’t got any of it saved as it didn’t work, however were trying to use the following in a script to set the From field. We’ve tried both in a mail script and in the From Generation Type - Script section: email.setFrom(current.”Service Desk ”);

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?

Allen Andreas
Administrator
Administrator

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.

https://docs.servicenow.com/bundle/rome-servicenow-platform/page/administer/notification/task/t_Crea...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!