How can I get the sys_id of an approver within a workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2019 10:06 AM
Can someone please tell me how to store the sys_id of an approver into g_scratchpad?
I need to save the sys_id of the person that approved an "Approval - User" activity in a workflow to use later in the same workflow.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2019 10:36 AM
Hello Kent,
Add below code in approver activity or any of the activity and then using workflow scratchpad you can access it,
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval','current.sys_id');
gr.query();
if(gr.next()){
workflow.scratchpad.approvarName = gr.approver;
gs.print("Approver SYS ID:"+gr.approver+"Approvar Name:"+gr.approver.name);
}
Workflow scratchad :
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2019 10:50 AM
Hello Kent,
If you have more than one approvars then use below script:
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval',current.sys_id);
gr.query();
var approvers =[];
while(gr.next()){
approvers.push(gr.approver.toString());
gs.log("Approver SYS ID:"+gr.approver+"Approvar Name:"+gr.approver.name);
}
workflow.scratchpad.approvarName = approvers;
gs.log("All the approvers:"+approvers);
Abhishek Gardade