Power Automate,  Power Platform

Bulk Approvals Using Parent-Child Flows and Concurrency Control

Hello there! In today’s blog post we’re going to learn how to perform bulk instantaneous approvals using Parent-Child flows. We’re going to make use of “Concurrency” control, along with child flow instances to “theoretically” run as many as 2500 instances at once. To check the actual limits and throttling, refer to Microsoft doc

 

Let’s look at the case scenario!

 

Our organization is currently migrating thousands of SharePoint sites to a new tenant. You are tasked with reaching out to all the site owners to confirm if the site needs to be migrated, archived, or deleted. The team running the migrations is thinking of sending bulk notification emails to those owners. But from previous experiences, they know that most of the users just skip the email, which will later cause issues. Our task now is to send out individual approvals to all site owners and capture their responses.

 

Note: For executing this particular case scenario I’m using Excel. as the data source, but you can replace the excel actions with your choice of data source actions like SharePoint, Dataverse, or SQL.

 

Let’s get started by looking into the source file, where all the data is located.

Here we have the email information of the owners, the Site that belongs to them, and a column that captures their response.

 

Parent Flow

 

We’ll be using an Instant trigger, as we’re going to be starting this whole process manually. After which we’ll use a “List rows present in a table” Excel action to get the data from excel.

 

We’ll next be using an “Apply to each” loop to send out batches of 50 items to the Child flow, as the max concurrency setting for an “Apply to each” loop is 50. All we need to do now is, run the loop “Total Items divided by 50” times.

For this, we’re using a “range” function to generate an array that defines how many times we need to run the loop, and the “max” function will make sure that if the items are less than 50, we’re still capturing all the items.

 

range(0,max(int(div(length(outputs('List_rows_present_in_a_table')?['body/value']),50)),1))

 

 

Our next step would be to turn ON the concurrency for this loop and set it to max instances. To do this, click on ellipses and select “Settings”.

 

Turn on the radio input and set the “Degree of Parallelism” to 50, then hit “Done”

 

We’re using the blow expression to select a batch of items based on the current loop. The “item()” function will return the current loop item, in our case this will return us the number “loop Index -1”. We will use this to understand which batch of 50 items is to be sent to the child flow.

 

string(take(skip(outputs('List_rows_present_in_a_table')?['body/value'],mul(item(),50)),50))

 

Note: To select the child flow, it needs to exist first. You can skip adding this action to the parent after building your Child flow.

 

Here’s a snip of the Parent flow:

 

Child Flow

 

As the Child flow needs to be triggered by the parent, we will use an Instant trigger that takes a text input “InputArray”

 

We’ll first need to parse the object array using the “Parse JSON”, to make it easier for us to use the data.

 

We’ll now use an “Apply to each” action to loop over all the 50 items and send out the approvals. Obviously, we’ll also turn ON the concurrency and set it to the max, using the same steps from the parent flow.

 

Once the approval is done, we’ll capture the response back into our Excel using the “Update a row” action. The “Id” field is used as an identifier to find which row to update in the Excel file.

 

At the end of the flow, we’ll use the “Respond to a PowerApp or Flow” action to update the Parent flow about process completion.

 

Lastly, we need to set the “Run only users” for our child flow and pass connections for the Approval and Excel actions. We need to do this as the “Run a child flow” expects the connections of the child flow to be preset with some connections, else it won’t allow you to save the Parent flow.

 

Here’s a snip of the Child flow:

 

There we go! Both the Parent and Child flows are setup and ready to roll! All we need to do is manually trigger the Parent flow and all the approvals will be sent out instantaneously, ready to capture the responses into the Excel file.

Hope you found this post helpful. Until Next Time!

Leave a Reply

Your email address will not be published. Required fields are marked *