- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2022 10:23 AM
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:
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2022 06:59 PM
Hi
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,"");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2022 06:22 PM
Hi
Have you tried using the .replace() method on it?
// find the pattern of square brackets and anything inside them globally and replace with an empty string
var noCodeTags = internalComments.replace(/(\[.*?\])/g, "");
or an exact
//find the pattern "[code]" or "[/code]" and replace with empty string
var noCodeTags = internalComments.replace(/\[code\]|\[\/code\]/g, "");
That should work if the value from comments is an actual string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2022 06:39 PM
Pls let me know where do you want to add this code in the below 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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2022 06:59 PM
Hi
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,"");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2022 07:36 PM
Thank you
var comment = current.comments.getJournalEntry(1).split('\n')[1].replace(/\[code\]|\[\/code\]/g,"");