How to get the commentator and the comment when worknotes change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 09:58 PM
Hi,
Im trying to send a new comment on the worknotes using mail script but Im not getting the comment and the commentator, instead Im getting a sys id and an empty comment.
This is my mail script:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var commentorName = event.parm1;
var userGr = new GlideRecord('sys_user');
userGr.addQuery('sys_id', commentorName);
userGr.query();
if (userGr.next())
commentorName = userGr.name;
var comment = current.comments.getJournalEntry(1);
var commentTextIndex = comment.indexOf('\n');
var commentMessage = comment.slice(commentTextIndex + 1, comment.length - 2);
commentMessage = commentMessage.replace(/\n/g, '<br/>');
// template.print('<div style="line-height: 24px;color:#181A1F;">');
// template.print('<div style="text-align: center; line-height:36px; padding-bottom: 24px;' +
// ' border-bottom: 1px solid #DADDE2;"><span style="font-size: 24px;">' +
// commentorName + ' added a comment to your request</span></div>');
// template.print('<div style="font-size: 16px; padding-top: 24px; padding-bottom: 16px;">' +
// 'היי ' + current.caller_id.first_name + ',</div>');
// template.print('<div style="font-size: 16px; padding-bottom: 16px; ">' +
// commentorName + '<span style="font-weight: 600">' +'</span>:</div>');
// template.print('<div style="font-size: 16px; font-weight: 600;">' + '"' + commentMessage + '"' + '</div>');
template.print(commentorName + ": \"" + commentMessage + "\" ");
//template.print('</div>');
})(current, template, email, email_action, event);
This is what im getting:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 10:32 PM
@Ankur Bawiskar hi I tried your script and now Im not getting anything at all (the last row should display comment and name of user that send the comment but its empty:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 10:34 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 10:43 PM
are you sure on these 2 things?
1) notification is on incident table
2) did you debug what came in comments value?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 10:46 PM
@Ankur Bawiskar notification is on the incident table. I understood what was the problem with the user name and now Im getting it, but Im still not getting the comment value. It seems like this command does not get any value:
var comment = current.comments.getJournalEntry(1);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 10:50 PM
@Ankur Bawiskar what is parm1 represents, i know that parm2 is the sys_id of the user that commented: