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:
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.
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.
Once this flow has been created, it will be useful to test out the flow. This flow should now ask for a Team Id
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.
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.
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.
When you click on the edit link on the right near the Run-Only users you will get the following dialog.
For each connection you can select the provided run-only user and then select an existing connection.
Once this change has been made your flow will run and the child flows will be kicked off.
Get the results from the child flows
Now I use a Select action to collect the results from my child flows.
For the From settings use:
And for the Results mapping :
And now we have the results of all our child flows back.
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.
6 thoughts on “Get started with child flows in Power Automate”
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”?
Is your flow in a solution?
No. I have no idea how to add a flow to a solution. That is why I asked for the basics on this topic.
This should get you started.
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.
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.