Start a flow in a canvas app (retired)
You can use Power Automate to create logic that performs one or more tasks when an event occurs in a canvas app. For example, you can configure a button that performs a single task or multiple tasks. When the button is pressed, an item is created in a list (Microsoft Lists), an email or meeting request is sent, and a file is added to the cloud. You can configure any control in the app to start the flow, which continues to run even if you close Power Apps.
Note
When a user runs a flow from within an app, that user must have permission to perform the tasks that are specified in the flow. Otherwise, the flow will fail.
Enable classic Power Automate experience
By default, the new Power Automate pane is enabled by default. To use the classic Power Automate experience to create a flow, switch back to the old experience manually.
Important
It’s recommended that you use the Power Automate pane to create a flow. The classic Power Automate experience should only be used for troubleshooting. The classic experience will be retired soon and won't be available.
Select Settings at the top.
Select Upcoming features.
Under the Retired tab, select Enable Classic Power Automate pane to set the toggle to On.
Prerequisites
- Sign up for Power Apps.
- Learn how to configure a control.
- A SharePoint site with two lists.
- List RepairShop contains Title, and ContactEmail columns.
- List Assets contains Title, AssetType, and RepairShop columns. The AssetType column is a choice column with choices such as "Desktop" or "Laptop".
- The RepairShop column in Assets list is a lookup column that gets values from the ContactEmail column in RepairShop list.
- Create a few items in the RepairShop list for sample contacts.
Create a flow
In this section, you create a flow using Power Automate that creates an item in a list using the input value for the list column from an app created using Power Apps. You create the app that uses this flow in the next section.
Sign in to Power Apps.
On the left-pane, select Flows.
Select + New flow > Instant cloud flow.
Enter flow name, such as FlowInApp.
Under Choose how to trigger this flow, select Power Apps.
Select Create.
Select + New step.
Under Choose an operation, search for or select SharePoint connector.
Search for, or select Create item action.
For Site Address, enter or choose your SharePoint site that has the lists Assets and RepairShop.
For List Name, select the Assets list.
For Title, choose Ask in Power Apps from the Dynamic content tab. The action automatically updates to Createitem_Title.
Choose values for AssetType Value, and RepairShop Id of your choice.
Select Save.
Important
Arguments that pass from Power Apps to Power Automate are visible as network traffic and can be intercepted. Most traffic is likely harmless data that are irrelevant outside the application, for example arguments like "yes" or "Redmond".
Evaluate the parameters passed to Power Automate and consider the consequences (if any) if they're changed by an exernal actor. To mitigate risks, validate the parameter values passed.
For example, if you send sensitive data to a person in your organization through email, for example someuser@contoso.com
, validate the address in Power Automate. You can check the incoming arguments to confirm the organization, @contoso.com
, and only allow the flow to proceed if the right organization is present.
Add a flow to an app
In this section, you create an app using Power Apps that uses the flow created in the earlier section. The app uses text entered in a text box when the button is selected to trigger the flow to create an item in the selected list.
Create a blank canvas app with a name such as AppWithFlow.
Select + (Insert) on the left-pane.
Select Text input control.
Select Button control.
On the canvas, move the button control below the text input control.
Select Action menu at the top, and then select Power Automate.
Note
Adding a flow to the selected control or component clears out any existing formula for the chosen property. For example, when you add a flow to a button's
OnSelect
property that has a complex formula, the flow addition clears out this formula. Ensure you make a copy of the formula before adding the flow. However, this behavior is different when adding flow with the Power Automate pane enabled. Learn more in Reference a flow.Alternatively, if you enabled the Enable Power Automate pane preview feature, you can choose your flow from the left-pane inside Power Apps Studio.
More information: Use Power Automate pane (preview)
Select FlowInApp.
In the formula bar, remove the formula for the selected OnVisible property.
Select the text input control.
From the top-left side of the screen, select the property list drop-down, and then select the Default property.
In the formula bar, change the default property value from
"Text input"
to"Enter Asset Title"
.Select the button control.
From the top-left side of the screen, select the property list drop-down, and then select the Text property.
In the formula bar, change the text property value from
"Button"
to"Create Asset"
.From the top-left side property list, select the OnSelect property for the button.
Enter the following formula in the formula bar.
FlowInApp.Run(TextInput1.Text)
In this formula, FlowInApp is the name of the flow you added using Power Automate. The .Run specifies the flow to execute. The flow executes with TextInput1 text input control added to this canvas, with the value entered in this text box (.Text).
When this button is selected, the app runs the flow with the value from the text input control, passing the text value to the flow to execute. And the flow creates the list item with this text input value along with rest of the selection inside the flow configuration.
Save and publish the app.
Test the flow
Now that you have both the flow and the app created, run the app and verify the creation of an item inside the selected list.
In Power Apps, select Apps, and then, select the AppWithFlow app.
Enter a value in the text input box, and then select Create Asset.
Verify that the item is created in your list.
Now that you created a sample app that runs a flow and adds an item inside a list, you can create more complex applications. Your apps can interact with Power Automate and manipulate data inside various data sources.