Hey there! Looks like you’ve stumbled upon this post on Child Flows in Power Automate! You must be looking to adopt a best practice for building flows, perhaps you want to make your flows easier to follow, and perhaps you even want to make development quicker by cutting out the repetition in your work… well, lucky you! In this post I’m going to discuss what child flows are in Power Automate, why you might want to implement their use and how to do so in your cloud flow development.
What are Child Flows?
It’s common that we might come across a scenario where the solution we put in place required lots of different parts and steps to it. In the case of Power Automate this can lead to us building enormous flows which do awesome things, but can tend to take ages to debug when they go wrong, and can be difficult to navigate and maintain.
This is where child flows come in. Child flows allow us to more easily manage these bigger flows and allow us to reuse ‘sub-processes’ or ‘tasks’ as such in multiple places or ‘parent flows’. Say for example I’m auditing things I’m doing in a solution by creating records in a table with data that describes what action I’ve taken. Now imagine that you have a solution with 50 cloud flows in it which all happen as a result of different user actions from a GUI, now I need to put those steps in my flow to audit what they’ve done in every single flow! This is an example of something that could be a bit tedious.
The solution to this tedious problem is to create one flow with the steps needed to complete that sub-process, then just simply use one action in each of our bigger ‘parent flows’ to trigger that child flow and pass some inputs into it to give it something to use when carrying out its sub-process.
Prerequisite: To trigger a child flow, your flows both need to be in a solution. If your flows aren’t solution aware, you will run into issues when trying to implement child flows.
padding: 2% 2% 2% 2%;
border-radius: 0px 0px 0px 0px;
Implementing Child Flows
The first thing we need to do is create a flow that uses a button trigger. It’s important that you use this type of trigger, otherwise we won’t be able to call out child flow from our parent flow.
Create inputs in your flow trigger for anything that you will need to make use of in your flow that would be possible to get from your parent flow. For example if your parent flow is triggered from a Canvas app. Then you could use dynamic content that your app passes into your parent flow, and then further pass that into your child flow for information such as the user who clicked the button or the user that was running the app at the given time. If your child flow was to implement an audit of who actioned what with notifications say, then you’ve now got that information about who the user was, as an input to your flow.
Inputs look like fields on your flow step in your parent flow which we can populate with content.
So I’ve created myself a child flow with the actions in it needed to perform my ‘sub-process’ of auditing what I’ve done in my main process. My sub process includes creating a log or audit of my action and then notifying a team of managers that an action has been completed. I then respond back to my parent flow telling it that my flow was successful, though if it failed I tell it that it was not successful.
Now I’ve got my child flow which I can pass inputs to which will then handle my sub-process. How do I use this?
I’m going to head over to my parent flow, and show you how I will trigger my child flow from it. Simply add a step to your parent flow and look for ‘Run a Child Flow’.
Now you can select the child flow in your solution that you want to run. You can see mine in the dropdown below!
Once you select the flow, you will be able to populate the inputs of this flow using content from the flow you’re currently working with. In my case I was just updating the actioner to be able to create my audit item and put a person against the action, and then notify my managers of who actioned something.
Updating Child Flow Connections
Now go back to your parent flow and give it a save. Then test it! You can see below that this is the run history from my test focused on my child flow step. You can see the inputs I passed into my child flow which it was then able to use, and its provided my parent flow with outputs of true for the parameter success. Now I can do further error handling here to do a condition where my parent flow will continue if my child flow was successful, but it will terminate if my child flow wasn’t successful.
We can further make error handling really easy here by handling our error using a try-catch-finally in our child flow where we recieve a notification of error in our catch, but we can also include information about the flow that triggered our child flow in case there is a problem with the inputs being passed to our child flow that is causing the failure.
Check out this post by Pieter Veenstra on finding the parent flow from the child flow in Power Automate.
I hope this post helped! If you have any questions or you need help further with child flows, pop them in the comments below.
Continue your Power Platform journey with more great blogs on Power Platform Week.
About the Author
Microsoft 365 & Power Platform Consultant • Blogger • Community Contributor • #CommunityRocks • #SharingIsCaring
Baybutt, L., 2023, Child Flows in Power Automate. Available at: Child Flows in Power Automate – Low Code Lewis [Accessed on 17 January 2023]