Trying to remove the name from the additional comments being passed to a notification.

LRhodes
Tera Guru

Hi,

I'm trying to remove the name of the analyst that has added additional comments to an Incident from the notification that is then sent to the customer informing them that comments have been added.

I've followed a couple of techniques found on these forums but I think they may be a bit dated as they're not working for me. The first approach was as below;

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

            var comments = inc.comments.getJournalEntry(1);
			var com = comments.split("\n\n");
	
			for (var i=0; i < na.length; i++){
				
				var timestamp = /^(\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2} - )(.*)/;
				
				var output = com[i].replace(timestamp,"$1 (Additional Comments)");
				
				template.print(output);
				
			}

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

I've then called this script from the notification, however the email is still displaying comments as before;

find_real_file.png

The other method I've tried was as below but the outcome was the same in that it doesn't change how it's displayed from the above screenshot;

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

          current.comments.getJournalEntry(1).match(/\n.+/gm).join("\n");
          var dateRE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;

	  template.print(comment.replace(dateRE, ''));

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

Any advise would be really appreciated as I can't find much help outside of these two approaches and neither of which look to be working for me.

1 ACCEPTED SOLUTION

You can use this 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);
Thank you,
Palani

View solution in original post

5 REPLIES 5

Hi @palanikumar ,

i have similar requirement, but we need to show role name instead of user name, so we have created role as "pl admin", so we need to display the role name whoever have that role, otherwise keep the name, is this possible, if yes please help me how to achive this