Child flows in Power Automate

Child Flows is one of the subjects that has been on my list of things to write about for quite a while. In this post the steps to get started with child flows.

My example flow

In this post I will create a flow that collects all tasks from all plans for all teams in my tenant. I wrote a post about this a while back in this post i’m going to use the collect all tasks from Planner flow as an example.

The basic flow looks like this:

a flow without child flows

So how about replacing the apply to each steps with a child flow?

Creating a child flow

First of all, you can only call a child flow if your flows are part of a solution. So do make sure that you add your flows to a solution otherwise things will not work.

Then I created a flow that starts with a manual start and ends with a respond to a PowerApp or flow.

In between these steps I add all the steps that I already had in my original flow. The only difference is that i’m now getting the TeamId from the trigger.

Get started with child flows in Power Automate Microsoft Office 365, Microsoft Power Automate image 30

For the result output parameter I’m referring to the List tasks output as described in one of my previous posts about referencing actions inside apply to each steps.

outputs('List_tasks')

Once this flow has been created, it will be useful to test out the flow. This flow should now ask for a Team Id

Get started with child flows in Power Automate Microsoft Office 365, Microsoft Power Automate image 31
Completing this form will run the child flow and we know that all will work later on.

Creating a parent flow

So now I created the parent flow and added the run a Child flow action for each team that I find in my tenant.

Child Flows called from a parent flow

But it is not as easy as that!

Update the child flow for action ‘…’ to not use ‘run-only use’ connections

When you run the flow you will find quite quickly that you get the following error:

Update the child flow for action ‘Run_a_Child_flow’ to not use ‘run-only use’ connections.

Get started with child flows in Power Automate Microsoft Office 365, Microsoft Power Automate image 33

Ok, what does that mean?

We will have to correct some connections within the child flow. This can be done by going to the child flow in Power Automate.

Get started with child flows in Power Automate Microsoft Office 365, Microsoft Power Automate image 34

When you click on the edit link on the right near the Run-Only users you will get the following dialog.

Get started with child flows in Power Automate Microsoft Office 365, Microsoft Power Automate image 36

For each connection you can select the provided run-only user and then select an existing connection.

Get started with child flows in Power Automate Microsoft Office 365, Microsoft Power Automate image 37

Once this change has been made your flow will run and the child flows will be kicked off.

Get started with child flows in Power Automate Microsoft Office 365, Microsoft Power Automate image 38

Get the results from the child flows

Now I use a Select action to collect the results from my child flows.

A select collecting child flow output

For the From settings use:

outputs('Run_a_Child_flow')

And for the Results mapping :

json(item()?['body/Result'])

And now we have the results of all our child flows back.

Get started with child flows in Power Automate Microsoft Office 365, Microsoft Power Automate image 40

Benefits of child flows

There are some benefits of these child flows. The number of Apply to each steps can be reduced and therefore the method of referencing actions inside apply to each will work better. This referencing is only allowed for 1 level of apply to each steps. As soon as you have nested apply to each steps it is impossible to use this method.

Using child flows performance will not really help performance as there is a bit of overhead. But separating that one large flow into smaller flows could quite well be very helpful with error handling. You could even thinking about adding the Try-catch pattern to each child flow might quite well help debugging the flows as you can direct people directly to the child flow run that failed.

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

6 thoughts on “Get started with child flows in Power Automate”
  1. Can you point us to any intro articles on child flows and setting up solutions and the basics of this topic? And why does ‘Run a child flow’ not show up in my as one of the available “operations”?

      1. No. I have no idea how to add a flow to a solution. That is why I asked for the basics on this topic.

      2. Okay, I used the instructions. I created the solution & a publisher, and within the solution I added a parent flow and child flow. I was able to add the “Run a child flow” operation. It told me to “Update the child flow for action … to end with a response action” so I went back and did that then I could update the parent and then it worked.

        I am not sure how this all will help me right now. Maybe in the future I will be able to do something with it. In order for this to help with my existing flows, I would have to re-write them all from scratch in the solution, and I don’t think it is worth it yet to spend time on that.

        There are probably other good reasons to use solutions for things. I will try to find a better website that explains why & when to use them. The Microsoft docs don’t explain well the why, only the how.

      3. The main reasons for solutions are:
        – bundling parts that go together. Such as Dataverse tables, Apps, flows etc
        – deployment between environments.
        – protection of solutions in production environments. Typically solutions in production environments are managed solutions. Managed solutions cannot be modified. Whereas unmanaged solutions are used in development and can be modified.

        Please feel free to open a chat next week and I am happy to discuss the further.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading