Trigger flow from web part

Copper Contributor

Hi, I'm pretty new to sharepoint and I'm wondering if there is a way to directly trigger a flow from my sharepoint web part instead of in the list page. 

 

Right now I have a button in a list to start a flow and it only works in the list page, not the web part. Is there a workaround for this?

 

Thank you!

2 Replies

Hi @mingyk,

To trigger a flow from a SharePoint web part you can try to use a Power Apps button.

Here are the steps on how to create a Power Apps button and trigger a flow from a SharePoint web part:

  1. Create a Power Apps button.

    • Go to Power Apps and create a new canvas app.

    • Add a button to the app.

    • In the OnSelect property of the button, add the following code:

      Launch(
          "https://flow.microsoft.com/manage/environments/{EnvironmentName}/flows/{FlowID}/run"
      );

      Replace {EnvironmentName} with the name of the environment where your flow is located and {FlowID} with the ID of your flow.

    • Save and publish the app.

  2. Embed the Power Apps button in a SharePoint web part.

    • Go to the SharePoint page where you want to add the button.
    • Add a Power Apps web part to the page.
    • In the App property of the web part, select the Power Apps app that you created.

  3. Create a flow to be triggered by the Power Apps button.

    • Go to Power Automate and create a new flow.
    • Select the "When a button is clicked" trigger.
    • In the OnSelect property of the trigger, select the Power Apps button that you created.
    • Add the actions that you want to perform in your flow.
    • Save and run the flow.

 

Here are some useful links regarding your issue:


Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.


If the post was useful in other ways, please consider giving it Like.


Kindest regards,


Leon Pavesic
(LinkedIn)

@LeonPavesic 

 

Hi,

I face the same problem that was stated in the original post.
Sadly the solution presented creates a button for a single powerapp call
However, as the included webpart is a list (or in my case) a library, the powerapp call should act on a single line in the library or list. 

Is there a way to achieve that?
For example, can I include information about a selected item in the list/library to the flow call for the button you suggest. Even then I have an issue.
In the library I have set up the column with the flow-starting button with the column formatting option. In that script I also included conditions that would show or not show the button for that line, In that way I can prevent the flow being triggered if not all required fields are filled for the item. With a single button outside of the list that would also prove difficult, i fear.

I added the library as a web part so I could add a general description about the library and the available views. So right now, I either have to forego the description or the automation.