- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2022 06:48 AM
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;
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.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2022 05:00 AM
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);
Palani

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2022 07:29 AM
Hi,
Are you looking for the output like below?
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var comment = current.comments.getJournalEntry(1).split('\n')[1];
template.print(comment);
})(current, template, email, email_action, event);
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2022 02:07 AM
Thank you - this is close to what we want but this method also takes out the date and time stamp which ideally we would like to keep. Any ideas how we can keep that in?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2022 05:00 AM
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);
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2022 05:52 AM
Thank you - this is perfect!