Getting last comments on Approval record

samadam
Kilo Sage

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));
}

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

@samadam 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

samadam
Kilo Sage

samadam_0-1744686621196.png

Since this is a journal field I see it in the history that comments are added. 

@samadam 

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));
}
Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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.

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.