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.

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.

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", "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.

  1. Sign in to Power Apps.

  2. On the left-pane, select Flows.

  3. Select + New flow > Instant cloud flow.

  4. Enter flow name, such as FlowInApp.

  5. Under Choose how to trigger this flow, select Power Apps.

    Create instant flow using Power Apps trigger.

  6. Select Create.

  7. Select + New step.

  8. Under Choose an operation, search for or select SharePoint connector.

    Search or choose SharePoint connector.

  9. Search for, or select Create item action.

    Search or choose create item action.

  10. For Site Address, enter or choose your SharePoint site that has the lists Assets and RepairShop.

  11. For List Name, select the Assets list.

    Site and list.

  12. For Title, choose Ask in Power Apps from Dynamic content tab. The action automatically updates to Createitem_Title.

    Ask in Power Apps - create title.

  13. Choose values for AssetType Value, and RepairShop Id of your choice.

    AssetType Value and RepairShop Id.

  14. Select Save.

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.

  1. Go to Power Apps, or select Home in Power Apps.

  2. Under Make your own app, select Canvas app from blank.

  3. Enter an app name, such as AppWithFlow. You can also select or change layout between phone and tablet.

  4. Select Create.

  5. Select + (Insert) on the left-pane.

  6. Select Text input control.

  7. Select Button control.

  8. On the canvas, move the button control below the text input control.

    Design the app.

  9. Select Action menu at the top, and then select Power Automate.

    Action > 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.

    A screenshot showing the Power Automate button in the left pane with the Add Flow dialog opened, showing the FlowInApp flow available to add to the app.

    More information: Power Automate Pane

  10. Select FlowInApp.

  11. In the formula bar, remove the formula for the selected OnVisible property.

  12. Select the text input control.

  13. From the top-left side of the screen, select the property list drop-down, and then select the Default property.

  14. In the formula bar, change the default property value from "Text input" to "Enter Asset Title".

  15. Select the button control.

  16. From the top-left side of the screen, select the property list drop-down, and then select the Text property.

  17. In the formula bar, change the text property value from "Button" to "Create Asset".

  18. From the top-left side property list, select the OnSelect property for the button.

  19. 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).

    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.

    OnSelect formula for the button.

  20. 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.

  1. In Power Apps, select Apps, and then, select the AppWithFlow app.

    Run AppWithFlow.

  2. Enter a value in the text input box, and then select Create Asset.

    Run the app.

  3. Verify that the item is created in your SharePoint list.

    Check 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)

Important

  • 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.

Note

This feature must be enabled on a per-app basis.

To enable the preview feature:

  1. Select Settings at the top.

  2. Select Upcoming Features.

  3. 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.

    A screenshot of the Upcoming Features dialog box showing the Enable Power Automate feature toggle.

  4. The Power Automate button is added to the left-pane.

    A screenshow highlighting the Power Automate button in the left pane

  5. Select Add flow, and add flow to your app.

See also

Add and configure controls