Email script for Subject , sender and receiver details

Keerti2
Mega Expert

Email script for Subject , sender and receiver details :

Kindly help me to build   email script to get  email Icon , Subject/short description of ticket , Sender and receiver details as per below screenshot. for one of the notification they want to include this.

 

find_real_file.png

 

other than this there are few more data required like priority , state , assigned to ... i found this email script.

But i need same like above screenshot functionality .

Kindly help me code on same.

 

i tried below email script like below but not fetched details.

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
	
	var i18nSubject = gs.getMessage('Subject: {0}', '${short_description}');
	var i18nFrom = gs.getMessage('From: {0}', '${assigned_to}');

	
})(current, template, email, email_action, event);
4 REPLIES 4

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

This is activity sections and is shown automatically. You want to built this structure in your mail script?

 

Thanks,
Ashutosh

Keerti2
Mega Expert

-You want to built this structure in your mail script?

Yes  as per requirement we need to do this in "mail script"

Chirag A
Kilo Expert

Kindly help me to build   email script to get  email Icon , Subject/short description of ticket , Sender and receiver details as per below screenshot. for one of the notification they want to include this.

  1. Email Script: Hope, you are calling this script from the Notification; by putting below line in the Notification > Message HTML editor. 

    ${mail_script:script name} 

  2. Email Icon: This is not possible, or not sure what the ask here.
  3. Subject: To make subject as short description, see the code below.
  4. Sender: See the below code, if your sender info is present somewhere on record / system, you can fetch it first in below code and put instead of the hard-coded email string.
  5. Receiver: For Receiver address details; you need to modify the Notification's [Who Will Receive tab]. You should be able to find the receiver email from your record, or just hard-code in the first field of this tab.

other than this there are few more data required like priority , state , assigned to ... i found this email script.

  1. Other Info: Most of these information are directly accessible from your record and can be put directly to the notification body using the right side field's tree. 
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

        // Your code starts	
	//Considering that this email is triggered for the Incident record, and so current is a incident record

	email.setSubject(current.short_description.toString());
	email.setFrom('dev27348@servicenowdevelopers.com');
	
        // Your code ends

})(current, template, email, email_action, event);

..All the best

Chirag A

Servicenow Developer

aavenir.com

 

Chirag A
Kilo Expert

If you just have an issue with your existing code; then let me correct that one...

 

 


var i18nSubject = gs.getMessage('Subject: {0}', '${short_description}');

//above should be .... 

var i18nSubject = gs.getMessage('Subject: {0}', current.short_description.toString());



 

Chirag A

Servicenow Developer

aavenir.com