Email client templates when replying from the Record Activity

Marcel H_
Tera Guru

I've been working on a request from an internal team to send email from records within ServiceNow. Recently I added the glide.ui16.emailStreamResponseActions to show the buttons in the email stream, and the published workaround/fix to make sure that mail sent from those buttons updates the activity stream.

What I'm not sure about is where you can set an email client template like you can with the normal email client button. The same window pops up with using the mail stream buttons, but is pre-populated with different From and Reply to addresses than I want, and end users aren't going to want to delete what is there and change it (besides being prone to errors that way).

If there is a way to change the templates used, that would be great.

1 ACCEPTED SOLUTION

emaasalmi
Kilo Sage

In my actual script I'm calling another function to get the instance email address from a system property I have created for it, but basically you could just do:

getFromEmailForReplyButtons: function(){
	var fromEmail = '';
	if (current.target_table == 'u_customtable'){
		fromEmail = 'Mailbox display name <email.address@example.com>'
	}
	return fromEmail;
}

Or if you want to create a system property for your email address (preferred way!), you would get it from the property this way.

getFromEmailForReplyButtons: function(){
	var fromEmail = '';
	if (current.target_table == 'u_customtable'){
		fromEmail = gs.getProperty('your.property.for.instance.email');
	}
	return fromEmail;
}

View solution in original post

6 REPLIES 6

Great! This worked well in my scenario as well and was easy enough to set up with the script include.

 

Have you ever used your script to do this same thing conditionally for multiple tables, or different assignment groups within a single table so that the address can be changed automatically based on who is using it?

Nope, just for this. If you have multiple addresses for different tables, you could for example do a switch statement:

var fromEmail = '';
var tableName = current.getTableName();

switch(tableName) {
  case 'table1':
    fromEmail = addressForTable1;
    break;
  case 'table2':
    fromEmail = addressForTable2;
    break;
  case 'table3':
    fromEmail = addressForTable3;
    break;
  default:
    fromEmail = '';
}

return fromEmail ;