Madrid release - "Email Client Template" - Sender configuration script

david_legrand
Kilo Sage

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

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

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.

View solution in original post

2 REPLIES 2

Paul Curwen
Giga Sage

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. 

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

Chuck Tomasi
Tera Patron

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.