Add a "run flow" button to a list view in SharePoint
HTML-код
- Опубликовано: 31 окт 2022
- If you have an "Instant" flow configured in SharePoint ("For a selected item" or "For a selected file" triggers) and want to make it easier for folks to run that flow, this video is for you. I'll show how to add a column with a stylish button to run that flow.
NOTE: I recently learned that this process only works for flows in your tenant's default environment as there is no way to specify the environment in the JSON code.
Helpful links
Share an instant flow by adding run only users: learn.microsoft.com/en-us/pow...
(in order for others to be able to run the flow using that button, they need to be run only users)
Create a "Format only" column:
thechriskent.com/2018/08/29/l...
Advanced formatting concepts (Includes JSON code you'll need to copy):
learn.microsoft.com/en-us/sha...
Fluent Icons Search:
www.flicon.io/ Наука
I discovered your channel recently. I watched several videos, very good work. Superb presentation that gives me clues about an upcoming project. A channel to follow!
Thank you! Very helpful and easy to follow.
Hi Chad, it was easy, quick and to the point, thank you 👍👍
It is very helpful and handy way, I have used it and its quite popular in end user community. thanks Chad, have a good day
excellent Chad. Thanks a lot !
🔥🔥🔥🔥🔥🔥 love this. Thanks!!
Thanks for the video, very useful for someone new to Sharepoint and PA! Are you able to pass the line items over to PA on the row you have 'clicked' the button for?
This method works with the "For a selected item" ( or file) trigger, which returns the id of the item or file. You then use a "Get item" or "Get file properties" action to get the details of that item/file.
Hi Chad and many thanks for providing this tutorial. I am wondering if it‘s possible to present such buttons inside the list form. Background is a board based view where the button is not visible (and this is ok, i want to have clean/situation depending cards). But if the user clicks to open the form i would like to enable an „one click action“ to run a flow. Any hint if this is achieveable would be very appreciated.
Displaying the buttons on a card/gallery view is possible (just take the formatting code and replace it in the formatting for that view), but getting them to appear on the list form is (in my experience) more complicated. I've had a few cases where they just showed up there, but I've never been able to figure out why or make the formatting appear on a particular form. It's one of those things I keep on the back burner until I have some free time. I'm fairly certain I've seen Chris Kent demo that capability, but cannot find the video.
Awesome idea and video. Any idea if this will work with a document library?
Yes, as long as your flow uses the For a selected file trigger.
@@cvkealey gotcha. What was/is tripping me up is I cannot find “For a selected file” trigger when creating a new flow from scratch. I ended up using a template that has that trigger.
@@martinnoah9716it's classified as an "Instant" trigger. So, when creating a flow from scratch, select New > Instant cloud flow, then scroll down and you should see "For a selected file" in the list.
That was a helpful video. Do you have a link to your flow? how is it built
This will work for any flows that use the SharePoint triggers "For a selected item" or "For a selected file" and are connected to that particular list or library.
@@cvkealey Do you have an example of a flow where you get submitter name from a sharepointlist?
@@rafalstasiuk448 if by "submitter" you mean the person who created the item or file, that would just be the "Created by" value for the item. That's a person type field, so it has properties of DisplayName and Email (as well as a few others, but those are the most useful). If you mean (in the case of a manually started flow) the person who initiated it, the trigger will output several "User " properties (e.g.: "User name" is the display name of the person who initiated the flow run).
Thank you. And what if we don't want user to clock the "Run Flow" but rather directly run it? Is there any action for that
As far as I know, that's not possible. You can customize the flow launch panel to change the text that appears at the top and on the button to start it (see thechriskent.com/2019/05/02/customizing-the-flow-panel-with-list-formatting-actionparams/), but there's no way around the user needing to click that button to start the flow. I actually prefer this because it minimizes the risk of the flow being run unintentionally.
@@cvkealey you are great! The link is exactly what I was looking for
We have a few different workflows that we start this way (“For a selected item”). Is there a way to create a column but then have the button display a list of available workflow for the user to choose from? We are really liking the column approach, however, we would like to avoid having a column per workflow.
It is possible to show multiple buttons or links in the same column, each launching a different flow. The code below is from a task list where two different flows can be run. It might be possible to display a drop-down to select which flow, but that's beyond my abilities.
{
"$schema": "developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"style": {
"flex-direction": "column"
},
"children": [
{
"elmType": "button",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"66986db6-e468-4525-96f2-8c10085d93e2\"}"
},
"attributes": {
"class": "ms-font-m ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
},
"style": {
"border": "none",
"background-color": "transparent",
"cursor": "pointer",
"display": "=if(Number([$TasksGenerated]) == 0,'inherit','none')",
"padding-top": "6px"
},
"children": [
{
"elmType": "span",
"attributes": {
"iconName": "Trackers",
"class": "ms-font-xl"
},
"style": {
"padding-right": "6px"
}
},
{
"elmType": "span",
"txtContent": "Create tasks"
}
]
},
{
"elmType": "button",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"cfbb5367-58e8-4e89-8a70-35a4f95eb707\"}"
},
"attributes": {
"class": "ms-font-m ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
},
"style": {
"border": "none",
"background-color": "transparent",
"cursor": "pointer",
"display": "=if(Number([$TasksGenerated]) == 0,'none','inherit')"
},
"children": [
{
"elmType": "span",
"attributes": {
"iconName": "RecurringTask",
"class": "ms-font-xl"
},
"style": {
"padding-right": "6px",
"padding-top": "3px",
"padding-bottom": "6px"
}
},
{
"elmType": "span",
"txtContent": "Replace tasks"
}
]
}
]
}
the flow starts as an automated cloub flow and "for a selected item" and immediately to send an email or do I need a condition?
This method works with Instant cloud flows using the "For a selected item" or "For a selected file" triggers. The flow could just immediately send an email if that's what you want/need it to do. If you want that email to be conditional (example: "if this column's value is greater than this number" or "if this status column's value is approved"), then, yes, you would need a condition in that case.
should the flow be in the default environment as is the case for the out of the box button?
I have followed the exact steps and the flow is triggered on "For a selected file" but does not respond to the click
P.S in my case I don't have a list but a file
Apparently, this only works with flows in the default environment (see powerusers.microsoft.com/t5/General-Power-Automate/Trigger-Flow-from-SPO-List-button-not-working-if-flow-sits-in/td-p/619570). I was not aware of that limitation and will update the video description accordingly. I tried adding the environment to the json in what should be the correct format, but it simply doesn't recognize it as valid JSON.
@@cvkealey thank you! Very useful.
hi, i want to ask. what if i already created the approval flow in power automate where when the user click save button in the sharepoint list form, the approval automatically start. but then, what will happend if i create this button? how to stop the auto approval flow and use thing only
It sounds like you used the "When an item is created" trigger. You would need to remove that and replace it with the "For a selected item" trigger.
What kind of flow trigger would you use?
This will work with the "For a selected file" trigger in libraries and "For a selected item" trigger in lists.
Why does the column need to be read-only calculated? The button seems to appears no matter what the column type was. Also is there any way to make the button work in detailed view?
The column doesn't NEED to be a calculated column, but the main reason for using that is to prevent it from appearing in the edit form for an item and minimize confusion. To give credit where due, I got this idea from Chris Kent: thechriskent.com/2018/08/29/list-formatting-quick-tip-format-only-columns/. I'm not sure what you mean by "detailed view"...can you clarify?
@@cvkealey oh ok thanks.
"Detailed view"/popup/edit form, wasn't sure what to call it but the button doesn't work there(?).
@@somo1ful That is correct...I'm seeing the same behavior. It also doesn't work in a tiled/gallery or board type view of the list. I suspect there's a workaround for this, but don't know what that is. I'll have to do some testing.
Is it possible to visually ‘show’ when this button in the past has been pushed? This to avoid that another collegae push the button again.
You can add another column, like a date/time column, to record that the workflow has been started. If so, you can either just hide the icon/button, or show a different icon or message.
What does the Flow do? In one of your comments, you state the button sends the Id of the List item to the Flow and your Flow uses this information to send the email to the owner of the list item and also provide the List item's status?
The flow can do whatever you need it to do. By starting it "for a selected item", the ID of the item is automatically passed into the flow, so with that, you can get the full details of the item (using the Get item action) and do whatever you need it to do.
In other words, this is just a means of launching any flow that uses the "for a selected item" trigger.
Hi i have an issue, other users can't click the button. if they do nothing happens. if i click the button i see a process working in the upper corner and the flow is´triggered as well.
Any ideas?
Have you added those users as ”Run only" users to the flow? Without that access, they can't initiate the flow. See
learn.microsoft.com/en-us/sharepoint/dev/business-apps/power-automate/guidance/manage-list-flows
@@cvkealey Ty vm it works now, do you know how to get the users displayname or upn who started the flow into the http request? perhaps in the json body somehow?
Yup...see this video: ruclips.net/video/AGiv60AWCm4/видео.html
Got it TY vm!!! u are a life saver!
Can the run flow button be changed to say submitt?
Yes! There's an optional parameter (runFlowButtonText) that you can set to change the text displayed on the button. See thechriskent.com/2019/05/02/customizing-the-flow-panel-with-list-formatting-actionparams/ for details.
How do i add this button in the item? when you are in the list and press on a item?
If you mean in the "view form" for the item, I have not found a reliable way to do that. If you use a text column to hold the formatting and that column has a value (that is, it's not blank), then the formatting will appear in the form, but will not function as intended (it just lets you edit the value in the column rather than opening the flow launch panel).
How can we bypass the run flow button? Like the flow will just run automatically? Its just to streamline the process
Can't bypass the "Run flow" button. This is more to make the process of starting an instant flow easier to the end user, but not so easy that they'll do so accidentally. In fact, most such flows that I create have, in the description (which appears at the top of the launch panel) a warning of sorts. Something like: "NOTE: This flow will . If you DO NOT want to do this, click Cancel. If you do, click Run flow"
@@cvkealey Yeah, figured its by design behaviour of PA flows when running thru JSON format. I did a work around and use canvas app to fulfill my requirements.thanks btw.amazing content as always!
Will this work only to trigger flows in default environment? I tried to trigger a flow in different environment. It is not working. Is it possible to pass the environment I'd?
I have not tried with a flow in another environment. The instructions (see second link in the video description) for getting the id of a solution aware flow seem to indicate that it should work for flows in a non-default environment.
I think this approach is not working anymore. You have to apply the trigger "When a http request is received" to your flow. It is a premium trigger but it works without premium for now 🤷🏻♂️.
@@Myjestic12 the new flow editor doesn't like the "for a selected item" or "for a selected file" triggers. If you use the classic editor, it works fine. Trust me, I set up four of these this week.
@@cvkealey I used the Flow Id from My Flow->Export-> Get flow identifier. And now iam able to trigger flows from different environment
@@mithunmohan6927 good to know!
Hello,
If I give editor access to foe example 10 ppl to this same sharepoint list. and put button to run flow. I created flow in my "power automate and I am using that flow ID in that button. now if some other editor trigger flow, so the email will go under that editors name. how do I make this email sent from that person who trigger the flow. I have that person email column. can I somehow set that person?
For others to be able to run the flow, you need to make them "run only" users. See learn.microsoft.com/en-us/power-automate/create-team-flows for more details. When you do that, you can set whether the flow runs with their connections or yours. To have the flow send email as them, it needs to run with their connections.
@@cvkealey I can not see run only option in my flow. I can see Connections, Owners. Maybe I don't have admin access?
What trigger does your flow use?
@@cvkealey I convert my flow to manual trigger flow. It's working, because I can share access to the sharepoint editor. so the email send by who is triggering the flow.
Siiiiiiii🎉
i did exactly the same thing but it says : ,,Couldn't start flow "name of my flow". Failed " any ideas ?
What trigger does the flow use? This method *only* works with instant triggers from the SharePoint connector ("For a selected item" in lists or "For a selected file" in libraries). If you're using one of those, make sure you've got the proper/complete flow ID.
@@cvkealey it is a reccurence
@@xAdy11 then you can't trigger it using this method.
@@cvkealey ok, thank you. i will try another trigger
@Ady-sk4tj what does the flow actually do? Recurring flows usually operate on multiple items in a list, while the "for a selected..." triggers operate on a single item. They're both useful in different ways.