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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2019 12:30 AM
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?
Thank You!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2019 01:07 AM
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());
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2019 05:42 AM
Hi Vinayak,
Thank you for your reply!
Any idea how I can grab hold of the sys_id of my 'Approval-User' activity stage in the Run Script activity that succeeds it?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2019 09:44 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2019 10:00 PM
Go to Table wf_stage. Search for the activity name in the "Name" column, in your case search for "Approval-User". Check for the worfklow version with the workflow name. and you can grab the sys_is of that record.
Hit thumbs up if you find it useful.
Regards
Vinayak