How to get the sys_id of the approval record generated from the approval activity in workflow?

Community Alums
Not applicable

Hi,

 

I have a "Approval-User" activity in my workflow. How do I get the sys_id of the approval record that this activity creates?

find_real_file.png

 

Thank You!

6 REPLIES 6

nurav
Tera Expert

Hi Shruthi, Did you get a solution for this? I am in need of the same

If you have the current record and the sys_id of the stage you can get the sys_id of the approval record.

var aaprovalRec = new GlideRecord('sysapproval_approver');
aaprovalRec.addQuery('document_id','current.sys_id'); //current record for which the approval is attached
aaprovalRec.addQuery('wf_activity.stage',stageSysID); //sys_id of the stage in wf_stage 
aaprovalRec.query();
if(aaprovalRec.next()){

gs.print(aaprovalRec.sys_id.toString());
}