- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2019 05:51 AM
With Madrid release, we now have more possibilities on the Email Client Template for the Sender Configuration.
On the documentation, we have a "script" option
Script: Enter a JavaScript script that runs a GlideRecord query and matches it to the target record of the table for the email client. Determines the email From address to be used in the email client.
Do you have any example of how to retrieve data from the record? I tried:
- current
- parent
- source
- target
But none of them is actually valid.
Thanks,
David
Solved! Go to Solution.
- Labels:
-
Notifications
- 1,637 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2019 09:03 AM
The comments in the script indicate two objects fromAddressQuery and targetRecord. You can use the targetRecord to access data on the record being displayed and modify the fromAddressQuery to filter the addresses available in the list table. Here's an example
(function (fromAddressQuery, targetRecord) {
/**
* fromAddressQuery: A GlideRecord on the table "sys_email_client_from_address". Add conditions to filter the
* the email addresses displayed in the Email Client.
* targetRecord: A GlideRecord representing the record in which the Email Client was opened from
*/
var country = targetRecord.getValue('country');
if (country == "us")
fromAddressQuery.addQuery('email_address', 'servicedesk.us@example.com');
else if (country == "japan")
fromAddressQuery.addQuery('email_address', 'servicedesk.jp@example.com');
else if (country == "uk")
fromAddressQuery.addQuery('email_address', 'servicedesk.uk@example.com');
})(fromAddressQuery, targetRecord);
I've let the proper people know the docs can use some help in this area.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2019 08:56 AM
Hi David,
Agree, that documentation is poor and just leaves you hanging. Hopefully this upcoming event will help 🙂
https://community.servicenow.com/community?id=community_blog&sys_id=2f7b67abdb01f7c454250b55ca9619c1
if not, you can ask the question on the Webinar and put Chuck and Kreg to the test
Regards,
Paul.
Regards
Paul

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2019 09:03 AM
The comments in the script indicate two objects fromAddressQuery and targetRecord. You can use the targetRecord to access data on the record being displayed and modify the fromAddressQuery to filter the addresses available in the list table. Here's an example
(function (fromAddressQuery, targetRecord) {
/**
* fromAddressQuery: A GlideRecord on the table "sys_email_client_from_address". Add conditions to filter the
* the email addresses displayed in the Email Client.
* targetRecord: A GlideRecord representing the record in which the Email Client was opened from
*/
var country = targetRecord.getValue('country');
if (country == "us")
fromAddressQuery.addQuery('email_address', 'servicedesk.us@example.com');
else if (country == "japan")
fromAddressQuery.addQuery('email_address', 'servicedesk.jp@example.com');
else if (country == "uk")
fromAddressQuery.addQuery('email_address', 'servicedesk.uk@example.com');
})(fromAddressQuery, targetRecord);
I've let the proper people know the docs can use some help in this area.