Approval table get comments

Oyun-Erdene
Tera Contributor

Hi all,

I can't get comment on approval table.

var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('sysapproval',current.sys_id);
apv.addQuery('comments','!=',''); // add this to only find approvals that have comments on them
apv.query();

while (apv.next()) { // change if to while so it will go through all approvals with comments
task.short_description += "\nApproval Comments: from " + apv.approver.name + "\n" + apv.comments.getJournalEntry(-1); // add approver name here
}

that script not working.

2 REPLIES 2

RatneshTSN
Giga Guru

 

relation between Change Request & Approval , in approval table can be identified by document id

where document id is your change request number's sys_id

below scripts works to get all comments from sysapproval_approver table for said change request

var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('document_id','d2cdb552db252200a6a2b31be0b8f5ee');
apv.addQuery('comments','!=',''); // add this to only find approvals that have comments on them
apv.query();

while (apv.next()) { // change if to while so it will go through all approvals with comments
gs.info(apv.comments.getJournalEntry(-1)); // add approver name here
}

 

 

Hit Answer Correct & Helpful; if solved your queries or reply back if any other query

BigMikeyVegas
Tera Guru

var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('sysapproval',current.sys_id);
apv.addQuery('comments','!=',''); // add this to only find approvals that have comments on them
apv.query();

while (apv.next()) { // change if to while so it will go through all approvals with comments
task.description += "\n" + apv.state.getDisplayValue() + " - Comments from " + apv.approver.name + " for " + apv.wf_activity.name + ":\n" + apv.comments.getJournalEntry(-1); // add approver name here
}