Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

get list of approvals from RITM

Nani5
Tera Expert

Hi everyone,

I want to get the list of approvals related to RITM.Please help me with script.

var appr=[];
var gr=new GlideRecord("sysapproval_approver");
gr.addQuery('sysapproval',current.sysapproval.sys_id);
//gr.addEncodedQuery('sysapproval=9403d117db163218730e0e41ca96197d');
gr.query();
while(gr.next()){
gs.log("list of approvers "+ appr.push(gr.approver));
}

5 REPLIES 5

abhijitkhewale
Mega Expert

the logic for query is wrong that why you are not getting results, on sysapproval_approver table you dont have to pass sysapproval.sys_id but instead if you look at the sysapproval_approver table, request item is present as reference hence you should pass sys_id for current request item, make below changes in your code 

gr.addQuery('sysapproval',current.sys_id);