Remove [code] [/code] from Email notification

Hari7
Kilo Guru

I am trying to remove the assignee name from the email notification and I have created an email script as below. When I test the notification, I am getting [code] [/code] in the email notification and not finding a way to get this removed. 

Email Script:

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

    var date = current.comments.getJournalEntry(1).split('\n')[0].split(' - ')[0];
    var comment = current.comments.getJournalEntry(1).split('\n')[1];
	template.print(date);
	template.print(comment);	

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

Notification:

find_real_file.png

1 ACCEPTED SOLUTION

Hi @Hari 

Try at the end of the line where "comment" is being assigned:

var comment = current.comments.getJournalEntry(1).split('\n')[1].replace(/(\[.?*\])/g,"");

or

var comment = current.comments.getJournalEntry(1).split('\n')[1].replace(/\[code\]|\[\/code\]/g,"");

View solution in original post

8 REPLIES 8

Subrahmanyam2
Giga Guru
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {
    var internalComments = '${comments}';
    var date = internalComments.split('\n')[0].split(' - ')[0];
    var comment = internalComments.split('\n')[1];
	template.print(date);
	template.print(comment);	

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

Modified your code little bit. Please check and see if this works for you.

Changed the code and it appears as below. Assignee name is also appearing and "undefined" is also showing up at the end.

find_real_file.png

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
        template.print('<p><font size="3" color="#808080" face="helvetica">' + gs.getMessage('${comments}') + '</font></p>');
})(current, template, email, email_action, event);

You may try this code excerpt from OOB instance. You need not perform any split since the code will automatically take care of formatting.

OOB Code will not remove the "assignee name" from the notification. I wanted that to be removed from the notification.