SAP Builders Blog Posts
Learn from peers about their low-code journey and write your own blog posts to share your thoughts and experiences as you become an SAP Builder.
cancel
Showing results for 
Search instead for 
Did you mean: 
Dan_Wroblewski
Developer Advocate
Developer Advocate
916

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.

 

How I Did It

First, here's the project: https://github.com/sap-tutorials/sap-build-apps/blob/main/projects/spa-parallel-dyanmic-approval/Con... 

Subprocess

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. 

dan_wroblewski_0-1698415065182.png

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.

dan_wroblewski_1-1698415271741.png

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.

dan_wroblewski_0-1698415883819.png

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.

That's it.

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.

dan_wroblewski_2-1698416177345.png

Remember to set the condition editor to require all the conditions to be true. 

dan_wroblewski_1-1698416116918.png

It's not so great that you cannot differentiate between he "approval" output value of the various subprocess instances in the condition above.