WF Group Approval Activity results

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2018 03:01 PM
Hi Community,
Is there a way to set the result of a group approval in the workflow based on the amount of results by individuals?
For example: If an approval is assigned to a group that contains 5 people, and all of them must take an action (approve or reject). Let's say that 3 users approve and 2 user reject, then the result should be 'approved'. Meaning that whatever action taken combined is greater, that should be the result of the activity but all users must be taken into consideration.
I've looked at the Percentage based approval solution (https://www.servicenowguru.com/graphical-workflow/approval-percentage/ )that Mark Stanger has but I don't think that would achieve what I'm trying to do. I would like all users to take an action and then set the activity result based on what was greater, either approve or reject.
Is this possible? And if so, can you provide some guidance on how to get it done?
Any suggestion is truly appreciated!
Thank you,
Yeny
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2018 10:42 PM
Hello Yeny,
For the Approval Activity in the workflow, you can set the "Wait For" field to "Condition based on Script" and use the following script.
if(counts.requested == 0){
var approvePercent = 50;
if(counts.approved > counts.rejected){
answer = 'approved';
}
else
answer = 'rejected';
}
Through this, the script will run when all the users have provided the approval as approved/rejected.
Please, mark if the answer is helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2018 09:27 AM
Hi Eash,
Thank you! I tried the script but for some reason it is not ending the activity, it stills keeps running even after all the approval requests have been completed and I can't get it to end and move over to the next workflow activity .
I also tried it a different way but no luck either.
var approveCount = 0;
var approvePercent = 100;
if(approveCount == counts.total){
if(counts.approved > counts.rejected){
answer = 'approved';
}
else
answer = 'rejected';
}
Any ideas?
Yeny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2018 11:32 AM
Having the condition if(counts.requested == 0) completes the currently running activity. I tried working it on my demo instance.
Try keeping in logs to check if the flow goes inside the if loop when all the requests have been responded.
You can also change the first if condition to:
Option 1 : counts.total == counts.approved + counts.rejected
Option 2 : counts.total - counts.requested == 0
Let me know if you could navigate through.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2018 02:01 PM
I have to be doing something wrong then because it still isn't working for me.
This is what I have-
workflow script:
Approvals completed:
Workflow still saying 'state: Running' on activity
I tried the other options you suggested and still got the same result. I'm going to continue playing with the script