Need to calculate the approval count greater than 50% in the Approval group activity in workflow

sivaranjani3
Kilo Contributor

Hi All,

 

In the Change Workflow for a particular group i need to calculate the % approvals.If the % of Approvals greater than 50% then only it is supposed to be Approved.For this wrote a code and its working fine but i gave that in "APPROVAL USER ACTIVITY " in the workflow. If i change that to "APPROVAL GROUP ACTIVITY" its not working. My intention of changing the Activity from USER to GROUP is to get the Name of the Assignment group to which the Particular Approver belongs in the APPROVERS Related List in the Change Form.

 

Code used in Approval User Activity

try{

var approvePercent = 50;

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

  answer = 'approved';

 

}

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

  answer = 'rejected';

}

}

catch(e){

}

Please suggest if you faced this.

 

Thanks in Advance.

Sivaranjani.

9 REPLIES 9

Mark Stanger



Hi Mark,



Hope you are doing good.



Did you get any chance to look into it?   Just let me know in case you want any other details.



Thanks,


Vaigai.


Hi Vaigai,



If im not wrong you want the approval to be rejected when 50 percent of group members rejects the change rite??


If so you need to give if((group.rejected/group.total)*100 >= (100 - approvePercent)){


"=" is missing in your condition since you gave > it waits for more than 50 percent that is more than one person( if that group consists of two members)



Thanks


Sivaranjani


Hi @Mark Stanger What's the best course of action if each group needs a different number of approvers? Group 1 needs 4 people to approve, Group 2 needs 2 to approve, etc.

Something like that may require some sort of lookup table to match approval groups with the appropriate approval count.

I haven't tested this, but you could probably nest several group approval records (each with their own count script) within a single approval coordinator activity that could make the ultimate decision for that approval step.

Aatir
Tera Contributor

Hi..

I have undestood the script but one doubt.

(counts.rejected/counts.total)*100 > (100 - approvePercent)) - this line I did not get it.

If you could help me little. So I can clear the interview.

Thanks in advance