This quick tip is from a question posted in the community about how to create a process where I have 10 potential approvers for the process. At the start of the process the trigger indicates which approvers are needed, and all the approvers are asked in parallel with a branch. For each branch, here are the possibilities:
If approval not needed, return approved (true)
If approval needed and approved, return approved (true)
If approval needed and rejected, return rejected (false)
The obvious way to do it is to have a branch activity, and in each branch to have a condition to either automatically "approve" or require the approver to complete an approval form. The problem is, you cannot have a condition inside a branch.
I created a generic subprocess that can be used multiple times for each department that needs approval. First, I created input, outputs and variables:
Inputs: A boolean to indicate whether this approval was needed, and the email address to send the approval form in case it is needed.
Outputs: A boolean to indicate whether this approval subprocess passed.
Custom Variable: A boolean to save the results of the various paths, so I could then send this value to the output.
I then created a very simple process, where I check if the approval is needed.
If yes, we proceed to the approval step.
If not, we proceed to a decision step, which is just used to set the custom variable to false.
We also add a decision step to set the custom variable to true. We go to this decision step if he approval form is approved, or if no approval is needed.
Finally, in the end step, we set the output to the value of the custom variable.
Main Process - Part I
For the main process, I created a Boolean input for each department that may or may not need to approve the process, as well as an email address. For this test, I used the same email address – mine – to be the approver. I could have created a separate email input for each department, as well as for the text to put at the top of each approval form.
Then I created the process in 2 parts: The first is a branch for each department, and for each branch I put an instance of the subprocess.
I bound each of the process boolean inputs to the "approval needed" boolean input for the corresponding subprocess. I also bound the email input to each of he subprocess email inputs.
Main Process - Part II
After all he approval steps are complete, the process goes to a condition, which checks all the outputs of he subprocesses, and returns the appropriate response if the entire process was approved or not. You could also have other scenarios where it checks that you have a certain number of approvals, or any other scenario you want.
Remember to set the condition editor to require all the conditions to be true.
It's not so great that you cannot differentiate between he "approval" output value of the various subprocess instances in the condition above.