Start a flow in a canvas app
You can use Power Automate to create logic that performs one or more tasks when an event occurs in a canvas app. For example, configure a button so that, when a user selects it, an item is created in a SharePoint list, an email or meeting request is sent, a file is added to the cloud, or all of these. You can configure any control in the app to start the flow, which continues to run even if you close Power Apps.
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.
- 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", "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'll create a flow using Power Automate that creates an item in a SharePoint list using the input value for the list column from an app created using Power Apps. You'll 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 + 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 Dynamic content tab. The action automatically updates to Createitem_Title.
Choose values for AssetType Value, and RepairShop Id of your choice.
Add a flow to an app
In this section, you'll learn about creating 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 SharePoint list.
Go to Power Apps, or select Home in Power Apps.
Under Make your own app, select Canvas app from blank.
Enter an app name, such as AppWithFlow. You can also select or change layout between phone and tablet.
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.
Alternatively, if you've enabled the "Enable Power Automate Pane" preview feature, you can chose your flow from the left-pane inside Studio.
More information: Power Automate Pane
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
"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
From the top-left side property list, select the OnSelect property for the button.
Enter the following formula in the formula bar.
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).
In other words, when this button is selected, the app will run the flow with the value from the text input control, passing the text value to the flow to execute. And the flow will create the SharePoint 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, you'll run the app and verify the creation of an item inside the selected SharePoint 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 SharePoint list.
Now that you've created a sample app that runs a flow and adds item inside a SharePoint list, you can create more complex applications that interact with Power Automate and manipulate data inside various data sources.
Power Automate Pane (preview)
- This feature is being rolled out and depending on your region, it may not be available for your tenant yet.
- This is a preview feature.
- Preview features aren’t meant for production use and may have restricted functionality. These features are available before an official release so that customers can get early access and provide feedback.
With the "Enable Power Automate Pane " feature, you can add flows to your canvas app from the left-pane inside Studio.
This feature must be enabled on a per-app basis.
To enable the preview feature:
Select Settings at the top.
Select Upcoming Features.
Under the Preview tab, select Enable Power Automate Pane to turn on this feature. You may be prompted to close and reopen your canvas app to see the change.
The Power Automate button is added to the left-pane.
Select Add flow, and add flow to your app.