Changing approval count from percentage approval to a count

Urie1
Tera Contributor

Hello Everyone,

Im looking to change our workflow approval approval conditions from a percetage approval to an static approval count from the members. Im new to javascript and i wanted some feed back on how we can modify our current approval script listed below:

// Approve based on percentage from each group

var approvePercent = 50;
var approveCount = 0;
for(var id in groups){
   var group = groups[id];
   if((group.approved/group.total)*100 >= approvePercent){
      //Mark the group approval record 'Approved'
      var groupApproval = new GlideRecord('sysapproval_group');
      groupApproval.get(id);
      groupApproval.approval = 'approved';
      groupApproval.update();
      approveCount++;
   }
   if((group.rejected/group.total)*100 > (100 - approvePercent)){
      answer = 'rejected';
      break;
   }
}
//Ensure all groups have approved
if(approveCount == counts.total){
   answer = 'approved';
}

Im thinking that that i would change the var approveCount to 3 and the var approvePercent to 0 but im not sure on how to change the rest of variables that are bolded. Also, do i need to make a modification to the approval definition make this a happen as well. 

1 REPLY 1

Ali Subhan_67
Tera Contributor