In this article, we will see how you can call a Power Automate - flow from Power Apps Canvas App. Also, we will see how we can pass parameters from the canvas app to Power Automate and return data from flow to power apps.
Prerequisite:
You need to create a Power Automate flow in which the trigger action should be Power Apps.
Call Flow from Canvas App
- Open/Edit your canvas app.
- Create a screen and place a button over there. This is just for example purposes, modify according to your requirement.
- As shown in the screenshot, click on the button (Start Flow here) >> from the top menu select Action, and then click on Power Automate.
- All the available flows will be listed. Select the flow or create a new flow if you don’t have it already.
- Run the power app and test. You can see your workflow is successfully run.
Trigger Flow with parameters
We may face requirements when we have to send parameters along with starting the flow.
When we are creating flow, we can easily Ask for parameters.
- Open/Edit your flow
- Tap on the field and you can choose the action – Ask in PowerApps
- You can see the variable name is picked based on the Action (SubjectName). We cannot change the name of the variable unless you do some tricks.
- Now, go to your PowerApps, edit it.
- Now when you select the flow, it will ask you to provide the parameter.
- Specify the parameters' name and you are good to go.
Return data from Power Automate to PowerApps
In this section, we will see how you can send data back from Flow to Power Apps.
- Open/Edit your flow.
- Add an action - Respond to a PowerApp or flow
- As shown in the screenshot, the first textbox contains the Key and the second textbox contains the value/data (Which will be sent back to Powerapps)
- Now go to your app. On the button, where you invoke the flow, write like mentioned in the below screenshot. Here, we are using the Set command so that it will run the flow and the flow output will be stored in a variable (Here - GetFlowData).
- Now, you can use this variable in your app. You can see we have set the label text using the variable.