Power Community

Power Community

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.

When to create child flows in Power Automate? Microsoft 365 image

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.

An example child flow

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.

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

ON DEMAND | SharePoint in-depth: Learning content

There’s the thinking cap. And then there’s the deep-thinking cap. It’s time to put on the latter. This article contains...

More Articles Like This

- Advertisement -spot_img