How can I remove the first approver from the list of approvers on a second approval from the same group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2019 05:29 PM
I have a workflow which has 2 user approval activities (First Approval and Second Approval), both approval activities are assigned to the same group. I would like to make sure the first approver is removed form the list of approvers for the Second Approval activity.
Although the same group will provide first and second approvals, it shouldn't be approved by the same person twice.
Can anyone help with how I can script this in the workflow?
- Labels:
-
Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2019 06:48 PM
Check the "Advanced" checkbox on the second Approval Activity and set the approver by script.
Get every user of the group except the user who approved the first approval.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2019 07:13 PM
So I have created the following script to accomplish this, which worked for a while and then started adding the previous approver.
// Get the last approver for this record
var last_approver = '';
var appRec = new GlideRecord('sysapproval_approver');
appRec.addQuery('state', 'approved');
appRec.addQuery('document_id',current.sys_id);
appRec.orderBy('updated');
appRec.query();
while (appRec.next()) {
last_approver = appRec.approver.toString();
}
// loop through group members and add to array if not last approver
var answer = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", "583be867db42bf40e14ad92b5e96195f"); // sys_id of group "Template Releasers BMO & BOA"
gr.query();
while (gr.next()) {
var gr_user = gr.user.toString();
if (gr_user != last_approver) {
answer.push(gr.getValue('user'));
}
}
Any Idea what I'm doing wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2019 07:12 PM
So I have created the following script to accomplish this, which worked for a while and then started adding the previous approver.
// Get the last approver for this record
var last_approver = '';
var appRec = new GlideRecord('sysapproval_approver');
appRec.addQuery('state', 'approved');
appRec.addQuery('document_id',current.sys_id);
appRec.orderBy('updated');
appRec.query();
while (appRec.next()) {
last_approver = appRec.approver.toString();
}
// loop through group members and add to array if not last approver
var answer = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", "583be867db42bf40e14ad92b5e96195f"); // sys_id of group "Template Releasers BMO & BOA"
gr.query();
while (gr.next()) {
var gr_user = gr.user.toString();
if (gr_user != last_approver) {
answer.push(gr.getValue('user'));
}
}
Any Idea what I'm doing wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2019 07:21 PM
So I have created the following script to accomplish this, which worked for a while and then started adding the previous approver.
// Get the last approver for this record
var last_approver = '';
var appRec = new GlideRecord('sysapproval_approver');
appRec.addQuery('state', 'approved');
appRec.addQuery('document_id',current.sys_id);
appRec.orderBy('updated');
appRec.query();
while (appRec.next()) {
last_approver = appRec.approver.toString();
}
// loop through group members and add to array if not last approver
var answer = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", "583be867db42bf40e14ad92b5e96195f"); // sys_id of group "Template Releasers BMO & BOA"
gr.query();
while (gr.next()) {
var gr_user = gr.user.toString();
if (gr_user != last_approver) {
answer.push(gr.getValue('user'));
}
}
Any Idea what I'm doing wrong?