'Comments' in email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 06:14 AM
Hi,
I have a requirement to show 'comments' in the request rejection email notification. At the moment the script is not working. It just shows blank space for 'Comments'. Below is my notification, template and the script. Could someone help me where it's going wrong.
Thank you
Notification:
Template:
email script:
var comment = new GlideRecord("sysapproval_approver");
comment.addQuery("sysapproval", current.sys_id);
comment.query();
while (comment.next()) {
var comments = rec.comments.getJournalEntry(1);
template.print("<b>Comments:</b>" + comments + "\n");
template.print("<b>Comments:</b>" + comments.substring(comments.indexOf("\n")+1) + "\n");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 06:33 AM
Hi Riyak,
So what is the below line of code printing.
template.print("<b>Comments:</b>" + comments + "\n");
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 06:34 AM
Assuming you want the comments from the rejected approval associated with the request (and not the requested item) you would do something like this:
var approval = new GlideRecord("sysapproval_approver");
approval.addQuery("sysapproval", current.sys_id).addOrCondition("document_id", current.sys_id);
approval.addQuery("state", "rejected");
approval.query();
while (approval.next()) {
var comments = approval.comments.getJournalEntry(1);
template.print("<b>Comments:</b>" + comments + "\n");
template.print("<b>Comments:</b>" + comments.substring(comments.indexOf("\n") + 1) + "\n");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2022 02:53 AM
hi Brad.
how to do same for the requested item?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 06:43 AM
Hi Riyak,
Have you checked your Email Script in background script? Just to make sure if your Approval has comments or not. Check with one sysId of change and if it returns null, we can come to know that the comments is empty.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 07:21 AM
Hi Archana,
I've tested Brad's code in the background script. There is an error on line 2