- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 05:50 AM
Hello ,
Im getting [code] and [/code] while fetching latest worknotes alone through email scripts.
(function runMailScript(current, template, email, email_action, event) {
var fieldName = 'work_notes';
var rec = new GlideRecord('sys_journal_field');
rec.orderByDesc('sys_created_on');
rec.addQuery('name', current.getTableName());
rec.addQuery('element', fieldName);
rec.addQuery('element_id', current.sys_id);
rec.setLimit(1);
rec.query();
if (rec.next()) {
template.print("Below Worknotes have been added to the Case" + rec.value);
}
while (rec.next()) {
parsedEntry = (rec.getElement("value")
.getHTMLValue())
// .replace(/\[\s*(\/|)\s*code\s*]/gi, '');
.replace(/\[code\]|\[\/code\]/gi, "");
}
})(current, template, email, email_action, event); //
I have tried all the ideas posted in community but still didnt get it fixed.
Please suggest me if there is any solution
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 05:55 AM
Hi,,
Change the script as below
(function runMailScript(current, template, email, email_action, event) {
var fieldName = 'work_notes';
var rec = new GlideRecord('sys_journal_field');
rec.orderByDesc('sys_created_on');
rec.addQuery('name', current.getTableName());
rec.addQuery('element', fieldName);
rec.addQuery('element_id', current.sys_id);
rec.setLimit(1);
rec.query();
if (rec.next()) {
var parsedEntry = (rec.getElement("value").getHTMLValue()).replace(/\[code\]|\[\/code\]/gi, "");
template.print("Below Worknotes have been added to the Case" + parsedEntry;
}
})(current, template, email, email_action, event); //
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 10:46 PM
Hello Ankur,thanks got that [code] removed but got undefined in that place.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2022 10:10 PM
Hello Ankur,
The above code worked but I got undefined in place of [code].