When to create child flows in Power Automate?When to create child flows in Power Automate?

When you use solutions (and you always should use solutions!) there is the option to run Child flows. But when should you create a child flow?

What is a Child Flow?

A Child flow is a flow that can be started from another flow. Potentially taking parameters and potentially returning data back to the flow that triggered the child flow.

A basic child flow
A basic child flow

To take parameters to work with, the trigger can use input parameters. And similarly in the Response to a Power App or flow action a 1 or more return values can be specified.

when child flow manually
when child flow manually

Child flows and traditional programming languages

The Child flows can be compared with Functions, Methods or Procedures (Yes, I’m old enough to remember the Pascal programming language).

So in JavaScript you could for example have a function like this:

// Function to compute the product of p1 and p2

function myFunction(p1, p2) {
return p1 * p2;
}

Within Power Automate, Child flows are very similar to functions as they take data, do something and then return data.

When should we use functions/child flows?

Within traditional programming languages we have the same challenge as within Flow development in Power Automate.

A lot comes down to various programming patterns. People familiar with my blog posts will know that error handling is important when you develop larger and reliable flows. Also see my posts from a while back about Error handling in child flows. When you develop a Child flow you have the opportunity to add the Try Catch pattern, in the child flow. So if something goes wrong you can handle it as closely as possible to where the issue really is.

The other important element is that functions should always only do one thing. What is that, doing one thing?

The following examples are all doing one thing. I can describe what I’m doing with one sentence.

  • Work a day
  • Put one my coat
  • Drive to the office

Each child flow should be described with one small sentence.

Examples of doing multiple things are:

  • Work a day and drive home
  • Put one my coat and get an umbrella before walking to the shop.

So this could actually become difficult. What is one thing and what is doing multiple things?

How about “Driving to work ever work day.” Is this doing one thing or is this multiple things?

In programming languages another reason to use functions is reusability. If a function takes parameters then similar code can be reused just by varying the input parameters.

washcar(car1);
washcar(car2);
washcar(car3);

function washcar(car) {
 // Do whatever it takes to wash a car.
}

Back to Power Automate Child flows

So taking all of this back to Power Automate. When do we create a child flow? And when would it just be overkill/overengineering?

If you find that:

  • your flows do over and over almost the same thing (and your using more than 1 action) then looking at functions will be worth it.
  • some steps in the middle of many steps fail, you want specific error handling around those steps, then a child flow with its own Try catch may be worth it.
  • you can’t describe you flow in a single sentence then splitting the functionality across multiple flows may be useful.

The you definitely want to consider using child flows.

Do you have any flows that you want me to review then please feel free to open a chat.

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

4 thoughts on “When to create child flows in Power Automate?”

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