Call Power Automate flows from Power Apps components

Within you Power Apps there might sometimes be a need to call Power Automate flows, doing this from a component will reduce the number of flow calls that you need to configure.

Call Power Automate flows

When you call a flow from Power Apps, you will most likely use something like the following code

Set(varResult, MyFlow.Run("Any input"))

With the above code you can start a flow run and pass some data to the flow and then collect the result in a variable called varResult.

This is all quite easy and it can help when you need to do complicated stuff that you might struggle to do in Power Apps.

Power Apps components

Using components rather than rebuilding multiple groups of controls in your app can reduce the number of controls that you need to configure you simply create reusable components and you only need to configure the stuff inside the component once.

With input and output properties you can then ‘tell’ the component what you want it to do inside. That way you could create for example I component that displays a text that is passed in through a property.

Connecting flows and components

Today, I thought about creating an app in Power Apps that calls a Power Automate flow, but now I wanted to do this from a component.

I create my very simple flow that is called from Power Apps. Then it can do something and then it will return the data that it needs to return.

The most simple example of that is shown below

Call Power Automate flows

Within the Power App I created a component with just a button and i set the fill of the button to be fully transparent.

Call Power Automate flows from Power Apps components Microsoft Power Apps, Microsoft Power Automate image 68

Then I set the code of the button to call my flow.

Set(varResult, ComponentFlow.Run(MyComponent.ButtonName))
Call Power Automate flows from Power Apps components Microsoft Power Apps, Microsoft Power Automate image 67

The component that I created has two text parameters. An input parameter called ButtonName and a result property that is set to varResult.

The App containing the components

In my app I added 3 instances of my component and set the fill of the components to red, orange and green.

Call Power Automate flows from Power Apps components Microsoft Power Apps, Microsoft Power Automate image 69

As the button in the component is transparent, but not invisible I can now display which button I’ve pressed by looking at

MyComponent_1.FlowResult

Why call Power Automate flows from power Apps components?

In my above example I only configured 1 button and 1 flow to run potentially 3 separate things in a flow.

Especially when you need to update the flow connection you will now only need to update the component. This could for example happen when you add new input or output parameters to your flow or when you add new connections to your flow.

Often i have seen solutions where the same flow is called in multiple places of the app and then as the flow changes the app is broken as the developer didn’t realize that there were multiple calls to the same Power Automate flow.

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

5 thoughts on “Call Power Automate flows from Power Apps components”
  1. Interesting Article. But I believe there is dependency to enable access app scope to run flow and this option seems to be available for local component within app and not for the component library. If possible I would like to know how can we trigger flow or call http endpoint directly from the component library.

    1. I’ve just tested it and once I’ve enabled the feature the flow pane is available within the Component. I only found that I had to manually type the FlowName.Run() part in the OnSelect code.

      1. Hello, Pieter,

        First of all, very interesting article, thanks for the knowledge share!

        I just tried to add a flow in a component library and indeed, there’s no way to add a flow on a button. The Power automate menu entry in “Action” tab when selecting a button for instance does not show. However for components in an app context, the option shows.

        Regarding your last comment it seems you managed to make it work; what is the feature you said you enabled in the last comment?
        Thank you

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.