Additional comments in a notification email

ceraulo
Mega Guru

Hello!

How do I include the additional comments to a notification email containing only the contents and excluding the date/time stamp and submitter?

Thank you.

1 ACCEPTED SOLUTION

Raju Koyagura
Tera Guru

You need to depend on mail script to get this done...

 

Mail Script:

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {


var work_notes = current.work_notes.getJournalEntry(1); //replace with element name 
var regex= new RegExp('\n'); // searching for the first line break
var work_notes2=work_notes;
var i = work_notes.search(regex);
if (i>0)
{
work_notes2 = work_notes.substring(i+1, work_notes.length);
template.print(work_notes2);
}

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

 

Calling mail script in notification:

${mail_script:script_name}

View solution in original post

5 REPLIES 5

Slawek_Radziewi
Kilo Sage

You are adding it using variable which contain date and submitter.

You can try to create some kind of stripped field in the table and put this field to notification template.

Another approach is to create notification email script which will strip data for you before putting to mail.

i.e. *this is only an example I found in my system.

find_real_file.png

Raju Koyagura
Tera Guru

You need to depend on mail script to get this done...

 

Mail Script:

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {


var work_notes = current.work_notes.getJournalEntry(1); //replace with element name 
var regex= new RegExp('\n'); // searching for the first line break
var work_notes2=work_notes;
var i = work_notes.search(regex);
if (i>0)
{
work_notes2 = work_notes.substring(i+1, work_notes.length);
template.print(work_notes2);
}

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

 

Calling mail script in notification:

${mail_script:script_name}

This worked! Thank you for this.

Is there also a way to get the submitter of this additional comment?

01geraldine
Kilo Contributor

Thank you all. This is what I've been looking for. I gotta let our lazy ITSM team knows about this...