Social media


Tuesday, June 16, 2009

Different models of approval workflows - one approval, one rejection

In this post I will continue the previous post about different approval workflow models. There I showed how to create a "First response applies" workflow.

2) One approval 
In this scenario we need only one approval to approve an item, but to reject it we need all approvers to reject. This means if anyone approves - the item is approved. But the item is rejected only after the last person from the approvers rejects the item. 

Download the workflow definition
See a screencast on how the workflow is defined.

To create a workflow that will meet this scenario:
  1. Create a role "Approvers" and add selected users (you have to use NAMED users, do not use domain groups or SharePoint groups, later on you will see why). You can also add users later on with the activity "Add to role".
  2. Create a state "Waiting for approval".
  3. Add three actions "Approve", "Reject" and “Final rejection”. “Approve” and “Final rejection” can lead to where you want, for example to the ending state. “Reject” action must lead back to the “Waiting for approval” state (we are creating a loop).
  4. Assign the "Approvers" role to “Approve” and “Reject” actions. Remove permissions for everyone from “Final rejection”.
  5. In the “Reject” action add “Remove from role” activity. Use it to remove the “Current user” (use lookups to go to SharePoint -> Current -> Current user) from the “Approvers” role.
  6. In the “Approve” action add “Approve/reject item” activity and set it to approve the current item.
  7. Copy the activity to clipboard
  8. Open the “Final rejection” action and drag the activity from the clipboard. Change approval status to “Reject”
  9. Open the “Waiting for approval” status and click “Self-timer” button.
  10. Set self-timer to launch the “Final rejection” action 0 minutes after workflow enters this state. In the conditions set that the “Allow” membership of the “Approvers” role must be empty. Note: if you are using a workaround, the membership must be equal to “empty”.
What's going to happen in the workflow:
  1. Workflow enters the "Waiting for approval" state
  2. Members of "Approvers" role have 2 actions "Approve" and "Reject". “Final reject” is not visible, as they do not have permissions to launch it.
  3. If anyone from the approvers launches the action “Approve”, workflow exits the "Waiting for approval" state and item approval status is set to “approved”.
  4. If someone from the approvers launches the action “Reject”, then this person is removed from the “Approvers” and cannot launch any actions anymore. Workflow returns to the “Waiting for approval state”.
  5. Every time the “Reject” action is launched, workflow is entering the “Waiting for approval state” and self-timer condition is checked.
  6. If the person doing the rejection was the last approver in the role (everyone else already has rejected), then the role membership is empty. Self-timer condition is met, so the self-timer action will be launched. This is why you need to use named users – otherwise you would not be able to check if all members of a group have already rejected. Note that because timer is launched by SharePoint job action “Final rejection” will not be launched momentarily – it can take up to 5 minutes.
  7. “Final rejection” action is launched, workflow exits the "Waiting for approval" state and item approval status is set to “rejected”.
 3) All must approve 
In this scenario we everyone to approve the item. One rejection is causing the item to be rejected. This means if anyone rejects - the item is rejected. But the item is approved only after the last person from the approvers approves the item.

As you can see this scenario is exactly the same as the “One approval” – only the “Reject” and “Approve” are switched. Switch “Approve” and “Reject” action names, change “Final rejection” name to “Final approval” and change the activities between “Reject” (previously “Approve”) and “Final approval”.

Next post (voting approval)

No comments:

Post a Comment