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
Within the Power App I created a component with just a button and i set the fill of the button to be fully transparent.
Then I set the code of the button to call my flow.
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.
As the button in the component is transparent, but not invisible I can now display which button I’ve pressed by looking at
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.