Social media


            

Wednesday, June 17, 2009

Different models of approval workflows - voting approval


In the previous posts I have described the first answer applies workflow and multi-approval/multi-reject workflow.

In this scenario a number of rejection votes or approval votes are needed to approve or reject the item. For example – 3 approvals are needed for the item to be approved and 2 rejections are needed for the item to be rejected.  
Note that when setting up this kind of scenario you need to make sure that the voting algorithm will not cause a clinch where item cannot be accepted nor rejected. If you have 6 or more users, then 3 approvals or 2 rejections model is fine. If you have less than 6 users, then in some situations workflow could end in dead point. 
To create a workflow that will meet this scenario:
  1. Create a role "Approvers" and add selected users (you can assign users, domain groups or SharePoint groups). You can also add users later on with the activity "Add to role".
  2. Create a state "Waiting for approval".
  3. Add four actions – two named "Approve" and two named "Reject". One “Approve” and one “Reject” action must lead back to the “Waiting for approval” state (we are creating a loop). The other pair can lead to where you want, for example to the ending state.
  4. Assign the "Approvers" role to all “Approve” and “Reject” actions.
  5. Create 2 variables – “Approved votes” and “Rejected votes” – set both to “integer” type.
  6. In the looping actions add “Add to role” activity. Use it to add the “Current user” (use lookups to go to SharePoint -> Current -> Current user) to “Denied” members of the “Approvers” role. Note: use activity clipboard to copy the activity.
  7. In the looping “Approve” action use the “Set variable” activity to set the “Approved votes” variable to “Approved votes”+1.
  8. In the looping “Reject” action use the “Set variable” activity to set the “Rejected votes” variable to “Rejected votes”+1.
  9. In the non-looping actions add “Approve/reject item” activity and set it to approve/reject the current item.
  10. In the looping “Approve” action set action launch conditions to “Approved votes < 2”.
  11. In the looping “Reject” action set action launch conditions to “Rejected votes < 1”.
  12. In the non-looping “Approve” action set action launch conditions to “Approved votes >= 2”.
  13. In the non-looping “Reject” action set action launch conditions to “Rejected votes >= 1”.
What's going to happen in the workflow:
  1. Workflow enters the "Waiting for approval" state
  2. Members of "Approvers" role have 2 looping actions "Approve" and "Reject" – both “Approved votes” and “Rejected votes” variables are smaller than 2.
  3. Until two people chose “Reject” or “Approve” only the looping actions are available
  4. Every time the looping action is launched, a vote counter is raised by one and the workflow is entering the “Waiting for approval state”
  5. If 2 people have approved, then the looping “Approve” action will disappear and the other “Approve” action will be visible. This way the third approval action will be the one doing the final approval.
  6. If someone has already rejected, then the looping “Reject” action will disappear and the other “Reject” action will be visible. This way the second rejection action will be the one doing the final rejection.
  7. When the non-looping action is launched, workflow exits the "Waiting for approval" state and item approval status is set to “approved” or “rejected”.