Scripting To field in Email Client Template

milosnew
Tera Contributor

Is possible to set custom values in Email Client Template in To field using script includes?

I already tried, and getting like current is undefined?

1 ACCEPTED SOLUTION

Andrew Barnes -
ServiceNow Employee
ServiceNow Employee

Greetings Milo,

 The email client template system doesn't use the current.fieldname - instead it references the fields without current. This would seem to preclude the use of script includes that rely on using current object. Docs

-Andrew Barnes
Join me at Developer Blog

View solution in original post

7 REPLIES 7

Andrew Barnes -
ServiceNow Employee
ServiceNow Employee

Greetings Milo,

 The email client template system doesn't use the current.fieldname - instead it references the fields without current. This would seem to preclude the use of script includes that rely on using current object. Docs

-Andrew Barnes
Join me at Developer Blog

I wanted to calculate TO fields based on some parameters in script include. Is that possible?

Concrete, email client template is related to sys_email table.

You can add a mail script to your template that sets "To"-fields.
Is that enough? It will trigger on opening the email client, so you should know already then what data you are looking at. And mail script can see "Current" and then talk to script include.

I have some pointers on Notification Email Scripts here:
https://community.servicenow.com/community?id=community_article&sys_id=054deee5dbd0dbc01dcaf3231f961912

And I've done something similar to what you want, but I got my addresses from a comma-separated string with a few bits and bobs in one of the parameters, that I then used for, among others, setting addresses in To-field.

When I receive mail, it update incident. And I have option to reply all on that email. So I wanted email client opened that way to script and put some values in TO fields. I tried to put in TO field javascript: new ScriptIncludeClass().function(), but not good. current is undefined that way.

Did I explained as well?