How to get approval comments post-approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-12-2025 11:04 PM
Hello all,
I need to collect all comments and the actors making the comments (and their decisions). I am using the following script based on
// Get all approvers and comments
var arr = [];
var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('sysapproval', current.sys_id);
apv.query();
while (apv.next()) { // Go through all approvals with comments
arr.push("Approval Comments: from " + apv.approver.name + "\n" + apv.comments.getJournalEntry(-1));
}
var approver_hist = arr.join('\n');
gs.log("Approver History: "+ approver_hist,"RITM Post Approval Info");
The log shows the approver name but not the comments. What am I doing wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-12-2025 11:19 PM
where are you writing this script? please share screenshots
are you sure there are comments added by that approver?
if yes then only it will show comments
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
ā01-12-2025 11:42 PM
I read on this forum that another approach to try is to read the sys journal field, so I tried the following as well
var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('sysapproval', current.sys_id);
apv.query()
while (apv.next()) {
// Get comments for this approval
var commentGr = new GlideRecord('sys_journal_field');
commentGr.addQuery('element_id', apv.sys_id);
commentGr.addQuery('element', 'comments');
commentGr.orderBy('sys_created_on');
commentGr.query();
while (commentGr.next()) {
var commentInfo = {
approver: approvalGr.approver.getDisplayValue(),
comment: commentGr.value.toString(),
timestamp: commentGr.sys_created_on.getDisplayValue()
};
approvalComments.push(commentInfo);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-13-2025 12:29 AM
please share the complete script.
The above script is looking fine
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
ā01-19-2025 09:22 PM
Thank you for marking my response as helpful.
As per new community feature you can mark responses as correct.
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