Caroline Sosebee is a Software Engineer at ThreeWill. She comes to us with 20+ years of software development experience and a broad scope of general IT support skills.
I recently had a need to create an approval workflow that would assign an approval task to a group of people but would only need one person to actually approve or reject the request. I’ve worked on several fairly complex approval workflows but have never had to allow for this. So I searched around for a bit (how did us developers ever manage pre-internet?!) and I found this Stack Exchange question that gave me the clues I needed to get the job done.
It turned out to be a fairly simple process with only a few places that needed changes, via SharePoint Designer. I know this is only one of many ways I could have accomplished this, so feel free to modify to suit your own requirements.
Note: These steps assume an approval workflow has already been created and is editable.
Set the Task Process to Parallel
The first – and very important – piece is that the task process must be set to Parallel (all at once). The whole idea is that a group of people all have the authority to approve or reject requests but only one is needed to complete it. Thus, whoever can get to the request first will be able to complete the approval, effectively taking it off everyone else’s to do list. If the task process is set to Serial (one at a time), then only the first person in the approver list will be assigned a task initially. The rest of the group will not be assigned a task until each person in front of them completes theirs, which is counter intuitive to the whole idea here.
So here’s how to change this setting. First things first, edit the approval workflow.
Once open, click on the these users link (if you have already set this value, then user names will display here instead).
A dialog will open where you will find a dropdown that allows you to set how the tasks will be created – Parallel (all at once) or Serial (one at a time). After changing, click OK to return to the workflow edit screen.
Change the behavior of a single task
The next step is to modify the code in the When a Task Completes section.
You get here from the workflow edit screen by clicking on the name of your process in this case ‘CertificationApproval’. This will open the task process edit screen with various options that allow you to customize your task process.
Once the task edit screen opens, click on the Change the behavior of a single task link found in the Customization area.
Within the When a Task Completes section, add a ‘Set Workflow Variable’ action inside the IF statements for both the Approved and the Rejected checks that sets the IsItemApproved flag appropriately, based on whether Approve or Reject is clicked.
Change the completion conditions for this task process
The final step is to change the workflow completion behavior to be based on this flag.
Navigate back to the task process edit screen and from the same Customization area, click on the Change the completion conditions for this task process link.
When an approval workflow is first created, it generates code that checks task counts to determine if all the tasks have finished and if so, ends the task process. Obviously this will not work when there are multiple approvers (each with their own task) and only one approval or rejection is required.
By rewriting this block of code to check the isItemApproved flag (now being set when a task completes) instead of task counts, we can control when to end the approval process ourselves, instead of relying on counts.
All that needs to be done here is to replace the OOTB code with checks on the isItemApproved flag. Based on its value, you can perform any number of actions suitable to your own unique requirements. For mine, I only needed to log an appropriate Completion Reason and then call the End Task Process action which triggers the approval workflow to complete.
And that’s all there is to it. Publish the workflow and then start it for an item. Assuming that you’ve assigned a group of people to the approval process you will see multiple tasks created, one for each person.
If you then open one of the tasks and click Approve or Reject, you will see that the outcome for the one clicked will be set accordingly, all the other tasks for this workflow will be set to Canceled and the workflow itself will be marked as complete.