Call Child Flows

Enabled for Public preview Early access General availability
Admins, makers, or analysts, automatically - - This feature is released. Oct 23, 2019

Feature details

Today, people are building flows in Power Automate that need dozens or hundreds of steps; however, if you try to put all of these actions into a single flow, it can be difficult to navigate and maintain that flow. Instead, we recommend breaking apart your steps into different, smaller flows and calling back and forth between these flows. Each smaller flow can accomplish a single, discreet task, which is easier to read and identify a problem if something goes wrong. This approach is especially important where you want to reuse that task at multiple places in a flow, or even across multiple flows.

Previously, we shared how one flow could call another with the HTTP trigger and action. This is somewhat cumbersome because it requires copying and pasting the flow's HTTP URL. More problematically, with the introduction of solutions for flows, the HTTP approach no longer works if you export and import because when you copy a flow from one environment to another, it still points at the flow's HTTP URL in the old environment.

In October, we introduced a new built-in action called Run a Child Flow that automatically handles these problems. To get started with this action, select Solutions in the left side navigation and then pick an existing solution, or create a solution. Next, create (or edit) two flows:

  1. The parent flow: This flow can have any type of trigger and will call into the other flow.
  2. The child flow: This is the flow that is nested inside the other flow and contains the smaller tasks you want to run.

Let's look at an example where you have a child flow that you want to create or update a contact in Common Data Service based on that contact's name.

Building the child flow

You'll first need to create the child flow. Today, there are three different triggers you can use for child flows:

  1. Manually trigger a flow (under the Flow button for mobile).
  2. Power Apps.
  3. When an HTTP request is received (available only on the premium HTTP request/response connector).

When you select the first trigger you can define inputs that you want the child flow to receive from the parent flow. For example, if the child flow is going to be creating a contact, it will need the Contact name and Contact email. Select Add an input and provide the details.

Input for child flow

Next, you'll build the logic that you want the child flow to run. This logic can contain as many steps as you need. After your steps, you need to return data to the parent flow. In this case you can use one of two actions:

  1. Respond to a Power App or flow (under the Power Apps connector).
  2. Response (on the premium HTTP request/response connector).

As with the trigger, you can define as many outputs as you want to be returned from the child flow. In this example, we can respond with the ID of the contact.

Child flow response

Give your flow a descriptive name and save it. You need to then test your child flow. Because you can manually trigger this flow, it's very easy to test right inside of the designer. Try it out with a couple different inputs, and verify that the outputs are what you expect.

Lastly, if your flow uses anything other than built-in actions or the Common Data Service (current environment) connector, you will need to update the flow to use the connections embedded in the flow. To do this, select the back button to get to the child flow's properties page and then select Edit in the Run only users tile.

Edit flow

In the pane that appears, for each connection used in the flow, you will need to select Use this connection (<connection name>) instead of Provided by run-only user.

Select the connection to use

Then, you can select Save. At this time, you cannot pass connections from the parent flow to the child flow. If you do not do this, you will receive an error stating that the name cannot be used as a child workflow because child workflows only support embedded connections.

Building the parent flow

Now you can build the parent flow in the same solution in which you created the child flow. Simply create a new flow. Alternatively, you can bring an existing flow into that solution. This parent flow can have any type of trigger.

Find the place in your flow from which you want to call the child flow and add the Run a Child Flow action that's located under the Flows connector on the Built-in tab.

Next, you need to pick the child flow that you created earlier. As a reminder, you will only see the flows you have access to that are in solutions and that have one of the three triggers mentioned earlier.

Select the child flow to run

After selecting your child flow, you will see the inputs that you defined. After the child flow action, you will be able to use any of the outputs from that child flow.

Inputs

When the parent flow runs, it waits for the child flow to complete for the lifetime of the flow (one year for flows that use built-in connections and Common Data Service or 30 days for all other flows).

Finally, you can save and test this flow. When you export the solution that contains these two flows and import it into another environment, the new parent and child flows will be automatically linked, so there's no need to update URLs.