- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2020 10:30 AM
yes, you need to add run script activity after approval activity.
First you need to run script to get correct approval record after after approval activity. Also, you need to add timer after approval activity finishes
you can use below
var arr=[];
var gr= new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval',current.sys_id);
gr.query();
while(gr.next()){
arr.push(gr.getValue('sys_id')); //this will contain all the sys_id
}
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2020 10:41 AM
Sachin, unfortunately your suggestion won't work. Jerin wants to add a comment to the approval as that approval is created. As you know workflows will pause on Approval activities and remain on them until the approval has been approved or rejected so your suggestion of a run script AFTER this activity will update the approval too late.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2020 12:23 PM
What I ended up doing is creating a branch. One branch goes to the approval activity, the second branch goes to a run script. Then I joined the 2 activities.
Initially, I had a timer, but I was noticing that the comment would be after the initial notification for approval went, so I removed the timer.
I also wanted to add the requested_for as part of the comment which is why there are 2 glide record queries. I know it's clunky, but here is the code I used:
//Get value for Requested for user and pass to variable reqFor
var gr_req = new GlideRecord ('sc_req_item');
gr_req.addQuery('sys_id', '168251121b8fc410c19321fcbc4bcbd3');
gr_req.query();
gr_req.next();
var reqFor = gr_req.variables.service_recipient_name.getDisplayValue();
// Get Sys approval record for Supervisor Approval
var gr= new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval',current.sys_id);
gr.query();
//Add commment to Supervisor approval record
while(gr.next()){
var a = gr.wf_activity.getDisplayValue();
if (a == 'Supervisor Approval'){
gr.comments.setJournalEntry("Please acknowledge that you are approving local admin permissions for " + reqFor, 'admin');
gr.update();
}
}
Screenshot of Workflow:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2020 01:27 PM
Wel... I am listening to
Using .getValue instead of dot walking and using .get instead of using Query 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2020 07:42 AM
Maybe i'm not understanding the requirement but cant you just add ${comments} or ${sysapproval.comments} to your notification template for your approval notification?