Getting last comments on Approval record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 12:20 PM
I am trying to get the last comments on approval from workflow notification and using the following. It is showing empty. Any idea?
var gr1 = new GlideRecord("sysapproval_approver");
gr1.addQuery("sysapproval", current.sys_id);
gr1.query();
if (gr1.next()) {
template.print('Notes: ' + gr1.comments.getJournalEntry(1));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 07:59 PM
script is correct.
share screenshots which says comments are populated
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 08:11 PM
Since this is a journal field I see it in the history that comments are added.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 08:14 PM
the email notification is on which table?
you are writing that code in email script right?
did you add logs and see?
var gr1 = new GlideRecord("sysapproval_approver");
gr1.addQuery("sysapproval", current.sys_id);
gr1.query();
if (gr1.next()) {
gs.info('Record found');
template.print('Notes: ' + gr1.comments.getJournalEntry(1));
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 08:20 PM
Yes, I have the notification triggering from workflow on change table. In the notification event I have the mail script to pull comments from approval table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 08:53 PM
Figured out the issue, Wrong sysapproval record is being pulled with the query I have. Added the condition to check state as well and it got the right record and comments are being populated.