Power Automate is an incredibly powerful tool for automating business processes. However, since business processes are often complex, the corresponding flows can quickly become complex as well. This complexity makes testing difficult and maintenance even harder. To address this issue and make your flows more manageable, you can utilize child flows.
What are child flows?
Child flows are essentially regular “instant” flows that can be triggered from within another “parent” flow. They can be triggered at any point in your flow and function just like any other action.
Child flows have access to all the capabilities of instant flows, including flow parameters. This enables you to transfer data between the parent and the child flow.
How to build a child flow?
As mentioned, child flows are essentially regular “instant” flows. To create a child flow, you simply need to create a new flow with the “manually trigger” option.
Parameters are used to pass data between the parent and the child flow, allowing you to use this data within actions in the child flow.
How to trigger a child flow?
Child flows can be triggered from within any flow and are not limited to a single parent flow. Multiple parent flows can utilize the same child flow with different parameters.
To trigger a child flow, you can use the “Run a child flow” action from the “Flows” connector. This action can be applied to any instant flow. Depending on how the child flow’s parameters are set up at the trigger, the parent flow can provide specific data to the child flow.
The only distinction from a “regular” instant flow is that a child flow must always send a response back to the parent flow. This can be accomplished using the “Respond to PowerApp or Flow” action available in the “PowerApps” connector.
Why you should use child flows
Child flows offer several benefits in terms of keeping your flows organized. By splitting up logic into child flows, you can maintain cleaner flows. Adding too much logic to a single flow can cause delays or even break the entire flow. By dividing the logic into smaller, manageable child flows, each process can be handled separately.
Another advantage of using child flows is the ability to build generic Power Automate flows. These generic flows can perform specific tasks, such as creating a user task, based on parameters passed by the parent. By delegating the user task creation logic to the child flow, you avoid duplicating the same logic in other flows.
Task Example (using dataverse)
The following example demonstrates the utilization of multiple parent flows calling a child flow to create a user task. The child flow is responsible for handling all the logic related to task creation. If a task already exists, the child flow will terminate without taking any further action. However, if a task does not exist, the child flow will proceed to create a new task. The execution location of the child flow is irrelevant; its primary purpose is to maintain the task creation process in a generic manner.
The example consists of two parent flows. The first one is triggered every 15 minutes and is responsible for creating a task for a specific user. On the other hand, the second parent flow is triggered whenever a new user is created in Dataverse. This second flow then triggers the child flow to create a task specifically for the newly created user.