Forum Discussion
Trigger flow from web part
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.
You can achieve this by first triggering your workflow with the For a selected file SharePoint trigger. You can require input from the user when starting the workflow from this trigger (I required description of the change to the document.) Next, add a single line text column in your SharePoint library, and in the column formatting section, add this:
{"$schema":"https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json","elmType":"button","customRowAction":{"action":"executeFlow","actionParams":"{\"id\": \"{ID_OF_YOUR_FLOW}"}"},"attributes":{"class":"ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"},"style":{"border":"none","background-color":"transparent","cursor":"pointer","visibility":"=if(((indexOf([$ContentTypeId],'0x0120')) == 0),'hidden', 'visible')"},"children":[{"elmType":"span","attributes":{"iconName":"Flow"},"style":{"padding-right":"6px"}},{"elmType":"span","txtContent":"{WHATEVER_YOU_WANT_YOUR_BUTTON_TO_SAY}"}]}
My workflow started an approval process for a document in the library. The formatting above looked like this in the list.
and this is the beginning of my workflow
Hope that helps!