Best way to use approval group script for multiple approvers.

booher04
Tera Guru

I am trying to set up a group approval that only marks the request "Approved"   when 3 of the 4 members approve, we do not want it waiting for all 4, just until the first 3 that approve.   We do not have different groups, all of the approvers are in the same group.   I assume this needs to be done with the "Wait for: Condition based on script" approach.   Does anyone have any ideas on this or a better way to do it?   What we currently have in there is this:

var id,  

        count = 0;  

 

for (id in groups) {  

        count += groups["bc1b9479db590700ee2df456bf9619cf"].approved;   // Sums the total number of users who have approved from each group  

}  

 

if (count == 3) {  

        answer = 'approved';   // Approve if 3 users from any group have approved  

}    

else if (counts.requested == 0) {  

        answer = 'rejected';   // Reject if less than 3 users approved and no groups are still pending approval  

}  

1 ACCEPTED SOLUTION
4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Jeffrey,



You may find the below blog helpful.


https://www.servicenowguru.com/graphical-workflow/approval-percentage/


nitin_kumar
Mega Guru

Hi Jeffery,


I have used the following script to achieve something similar



var approvePercent = 50;


if((counts.approved/counts.total)*100 >= approvePercent){


    answer = 'approved';


}


if((counts.rejected/counts.total)*100 > (100 - approvePercent)){


    answer = 'rejected';


}



Thanks,


Nitin.



PS: Hit like, Helpful or Correct depending on the impact of the response


if rejetced i need to remove the records from the related list.

kindly advise

iamright
Giga Contributor

I used this for a percentage of approvers in the approval workflow.

 

I have 6 approvers.  I only 3....

 

if (counts.approved/counts.total > .49) {
answer = 'approved';
}
else if (counts.rejected/counts.total > .10) {
answer = 'rejected';
}