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.

Every child flow starts with a manually trigger a flow trigger and ends with a Respond to a PowerApp or flow action. You will need to make sure that that Respond step appears anywhere in the active steps of your flow run. Otherwise the parent flow will receive an error back and unexpected errors may occur in your process.

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.

trigger a child flow manually
trigger a 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.
}

Child flows and retries

Another important use of child flows can be to implement retries on actions that don’t support retries. One of these examples you can read about i my post about Retries in the Excel connector.

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 repeat 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 your flow in a single sentence then splitting the functionality across multiple flows may be useful.

Then 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.


Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Related Posts

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.