'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:18 AM
I think the issue is with this line:
var comments = rec.comments.getJournalEntry(1);
What is the rec referring to? If you want comments from the approval table you'll need to use the comment GlideRecord object you've defined instead and if you want comments from the request table you'd use current.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 06:21 AM
Sorry, that was a typo. It's actually,
var comments = current.comments.getJournalEntry(1);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 06:24 AM
So is your goal to take the comments from the request and put them in the email, or the comments from the approval? If it's the current request then you shouldn't need to do your gliderecord query on the approval table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2018 06:28 AM
I have to get 'Comments' from the approval.