The CreatorCon Call for Content is officially open! Get started here.

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

Ashutosh Munot1
Kilo Patron
Kilo Patron

Try this:

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

current.getValue('sys_id') this gets the sys id of RITM if the BR or this script is on RITM Table.

 

Thanks,
Ashutosh

Jaspal Singh
Mega Patron
Mega Patron

Hi,

 

Considering you are using it in background script you can use below.

var appr=[];
var gr=new GlideRecord("sysapproval_approver");
gr.addQuery('sysapproval.sys_id','Pass any RITM sys_id');
gr.query();
while(gr.next()){
appr=gr.approver.getDisplayValue()+','+appr;
//gs.print("list of approvers "+ appr.push(gr.approver.name));
}
gs.print(appr);

 

In case you use business rule then below.

var appr=[];
var gr=new GlideRecord("sysapproval_approver");
gr.addQuery('sysapproval',current.sysapproval.sys_id);
gr.query();
while(gr.next()){
appr=gr.approver.getDisplayValue()+','+appr;
//gs.print("list of approvers "+ appr.push(gr.approver.name));
}
gs.log(appr); //appr gives you approver names

Prateek kumar
Mega Sage

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

 
 

Please mark my response as correct and helpful if it helped solved your question.
-Thanks

asifnoor
Kilo Patron

Hi,

Where exactly you are running this script? Based on that the current object changes.

If you want to get a list of all approvals of specific RITM then in your code, change this line

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

gr.addQuery('sysapproval','RITM SYS ID'); //mention the ritm sys_id hardcoded or if you are running this in BR, then mention current.sys_id.

Remaining part of your code is fine.

 

Kindly mark the comment as a correct answer if it helps.