Button in SharePoint List to Trigger Power Automate

In SharePoint modern lists, conditional formatting can be done, and there is a great detailed reference by Microsoft.  I was trying to find a way to create a nice pretty button right there on a SharePoint list, to quickly click to run a workflow.

6/23/2022 Update:  I’ve written a newer, better way to accomplish this
(Action Button in a List – Set Column Value) – Scroll to the part of this new post that says “But Wait There’s More!”

With that in place, end users won’t have to wonder which menu and where to click in order to get that item approved (or run any workflow at all).

Microsoft’s reference on how to do this is here.

After reading this and trying it myself, I made a couple of tweaks to it, that you may like.  In this post, I’ll explain how it works, and what I did.  Here are a couple of examples, one with a list (Customers), and one with a library (Policies):

sharepoint-conditional-formatting-policies

There are two ways I’ll demonstrate, one way is with a hyperlink, and the other with a button.  The Policy Owner column above is a hyperlink, and the Button column is a button.

Check out my Advanced Power Automate Course

First of all, you’ll need to decide which Flow you want to run, and get the GUID of it.  Here’s how to create a flow if you don’t already have one, using a specific template for manager approval.  The important thing is that its trigger is based on the selected item, NOT based on when an item is created or modified.

  1. Go to https://flow.microsoft.com
  2. In your list or library, click the Flow drop-down in the toolbar, and choose Create a Flow.
  3. Choose the Flow called “Request manager approval for a selected item”.
  4. On the next screen, click Continue.
  5. Now, in the flow design screen, click Save at the top right.
  6. Go back to your list of Flows, and then open this Flow.  For any flow in your list, here’s how to get the GUID, it’s in the URL.
  7. My URL looks like this https: //us.flow.microsoft.com/manage/environments/Default-9d3ccee1-5cf8-4e08-887c-53b2a210967b/flows/de138f88-1e85-5d0f-a3ad-fa9b0c9e5ac5/details.  I just need that part in red.  Copy just that part to your clipboard.  de138f88-1e85-5d0f-a3ad-fa9b0c9e5ac5
  8. You’ll also need to share this Flow so that other people can run it besides you.  Add users or AD groups as run-only users:

Next, I’ll show you how to create the column as a hyperlink.  It doesn’t matter what kind of column it is, or even if it has a value in it or not.

My policy owner’s name is in a people column called Policy_x0020_Owner

    1. Go to your list or library, click on the name of the column, and click Column settings, then choose Format this column.
      sharepoint-format-polcy-owner-column
    2. Your pane will show on the right side of the screen, to paste this code in.

{
“$schema”: “https: //developer.microsoft.com/en-us/json-schemas/sp/column-formatting.schema.json”,
“elmType”: “span”,
“style”: {
“color”: “#0078d7”
},
“children”: [
{
“elmType”: “span”,
“attributes”: {
“iconName”: “Flow
}
},
{
“elmType”: “button”,
“style”: {
“border”: “none”,
“background-color”: “transparent”,
“color”: “#0078d7”,
“cursor”: “pointer”
},
“txtContent”: {
“operator”: “+”,
“operands”: [
“[$Policy_x0020_Owner.title]”,
Approval
]
},
“customRowAction”: {
“action”: “executeFlow”,
“actionParams”: “{\”id\”: \”86dfdf10-8d99-4914-8e98-fe4b21ed7e34\”}”
}
}
]
}

garth-fort-approval

  1. I’ve color coded the parts that I changed, to explain what each one is.
    Red – My Flow GUID that I obtained in that first set of steps above
    Purple – the name of my column.  The only reason I had to put the .title in it, is because it’s a person column.  All column types don’t need this extra part.  Reference.
    Blue – the word that I’m showing after the person’s name
    Green – the name of the icon that I’m showing in front of the person’s name.  This one is called Flow, but there are bunch of others here.

Next, I’ll show you how to create the column as a button, shown above in my Button column, which is just a text column with nothing in it.  Do step one from above first, then in the column formatting box, use this code:

{

{
“elmType”: “button”,
“txtContent”: “Get Approved“,
“customRowAction”: {
“action”: “executeFlow”,
“actionParams”: “{\”id\”: \”f191e7c8-1a36-4553-9d64-607764fc6f83\”}”
}

}

get-approved-button

This one is much simpler.  I didn’t make the text dynamic at all, it just says Get Approved for all of them.  Clicking the button launches my Flow.

Red – my Flow GUID.

Blue – the words on the button

What if I want the button to be a different color?  Then, the code would look like this instead, with a purple button with white text:

{
“elmType”: “button”,
“txtContent”: “Get Approved”,
“customRowAction”: {
“action”: “executeFlow”,
“actionParams”: “{\”id\”: \”86dfdf10-8d99-4914-8e98-fe4b21ed7e34\”}”
},
“style”: {
“background-color”: “purple“,
“color”: “white”

}}

purple-approval-button

What if you only want the button to show under a certain condition.  In this example, I only want this button to be visible if the content approval status is “Pending”.  Here’s the code for that:

{
“elmType”: “button”,
“txtContent”: “Get Approved”,
“customRowAction”: {
“action”: “executeFlow”,
“actionParams”: “{\”id\”: \”86dfdf10-8d99-4914-8e98-fe4b21ed7e34\”}”
},
“style”: {
“background-color”: “purple”,
“color”: “white”,
“visibility”: {
“operator”: “?”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“[$_ModerationStatus]”,
Pending
]
},
“visible”,
“hidden”
]
}
}
}

In the above code, here are the important parts:

Red – my column’s system name is _ModerationStatus

Blue – the value of the status is pending

In the syntax, a question mark (?) operator is used to create a condition, like an IF statement.  So, in the “visibility” section of the code above, we’re saying IF the ModerationStatus equals (==) Pending, then “visible”, otherwise (if it’s not pending), then “hidden”.

policies-approved-flow

Here’s my SharePoint Power Hour video where I demonstrated how to do all of this, along with how to do the workflow that works with the content approval status in the list/library.

2019-06-21_10-52-40.png

350 comments

  • Pingback: Personnaliser un flux d’approbation par Power Automate | KTNN SharePoint

  • can you execute a flow without the next step that always popup

  • Hey Laura-you’ve been so helpful over the years. The USMC is just now migrating from 13 to Online. Yeah I know…lol. I’ve been able to successfully automate a document set library with a 4 layer approval, however, I am trying to start it with a button – I want to insert the button on the document set welcome page. I have inserted it in the column like you did – thank you for that, but my flow just spins. Nothing seems to be wrong with it. I keep seeing that manual flows don’t work on document sets…but but but…this can’t be true…

    • Sorry I’ve never tried that on a document set, but it doesn’t surprise me that it doesn’t work, since a document set is really a folder, and folders can’t typically be triggers for flows.

  • Hey Laura,

    Loving some of the snippets you post up. Any chance you can extend this to include showing different buttons depending on status column… eg.
    if (approvalStatus) = ‘pending’ {
    buttontext = ‘submit for approval’
    elseif (approvalStatus = ‘approved’){
    buttontext = ‘set unapproved’
    }

    Can you do switches with formatting on columns? Do you have any good articles you’ve published about understanding the formatting options, or can link to any good resources?
    Thanks from Australia!

    • In the part of the post that starts with “What if you only want the button to show under a certain condition…” that’s where I show that syntax. I don’t know much more about JSON than that, though.

    • So in the example Laura provided. I tried it but didn’t work until I removed the underscore from the column name variable:

      “[$_ModerationStatus]”,

      So in my case it had to be changed to:

      “[$BookStatus]”,

      BookStatus being the internal name for the choice field in my Library Catalogue solution.

      Hope this helps someone!

  • Hi Laura

    Even the button is there and ID of Flow is adapted no action on click. Also I cannot see my flow to be launched manually on the corresponding sharepoint list. Is there anything I need to do on the flow itself in order to publish it on a specific list?

    • In step 2 of the instructions in the blog post, it says to go to your list, and click “create a flow”. That’s how it knows which list.

    • found it out finally…..as my Environment for Flows (Dev) is not the same as for the Sharepoint as such I needed to add the full path from the flow reference as you get on Export -> Get Flow Identifier and not only the ID that way it worked 🙂

  • Hi Laura – great Site. Worked for me that way. Is there any way to Handover a specific Field value from the List Row as a parameter to the Flow Input Fields?

    • The flow already knows all of the data about the item that you clicked on. There is already a get item action built in that gives you that data.

  • This is a very nice post. I have a question/concern. The button only launch the flow for the 1st time but if we cancel the launch and click on the button again nothing happens unless we refresh the page and click the button again. Is there any solution for it?

  • I noticed that the workflow’s trigger is “on a selected item/file”. is it possible to use the manual trigger instead so that I can use this workflow in other libraries?

  • Thanks WonderLaura. This is a great solution that I’ve used several times now so thanks for that. I have just found an issue which looks like a SharePoint bug or limitation perhaps and wondered if you had any knowledge of it. If I add the list into a Modern Page I can click on the button to launch the Flow but absolutely nothing happens. Any thoughts? What I really want to be able to do is offer the end user the ability to sit on their home page and launch the Flow so I thought having a dummy list to support this functionality would work well. If there’s another way you know of to allow a user to run a specific Flow from a Modern Page then I’m up for that!
    Thanks again, you’re one of my very few go tos

  • Hi, this code works for Azure Logic Apps? I’m looking to trigger an Logic App using a button in SharePoint Online.

  • Hi, do you know if it can be solved so it is possible to use this solution in a web part on a page? It is no longer possible to click on the buttons then

  • Hi Laura,

    I have been using similar JSON for a document approval workflow and haven’t made any changes to the JSON for the button column for months. Today the buttons for all the libraries where I have used the button, including different tenants, have stopped showing. The issue seems to be with the visibility section. If I change the section to “visibility”: “visible” and change nothing else in the JSON, all the buttons start showing (they show all the time, not just when the Approval Status is “Pending”). Does anyone else now have the same issue. It seems like a system wide issue as i have checked 5 different SharePoint Tenants and they all have the same issue.

    • Is no-one else having this issue? I thought someone would reply as it should affect everyone who used Laura’s approval button JSON above…..

    • I don’t know, Microsoft must have changed something in their code that determines whether something is visible or not.

    • Hi,
      I received an answer in another post I made in the Microsoft forums. It confirms there was a change in how the Approval status is handled with JSON. I am not super skilled in JSON so I don’t know what it means. Can anyone here help with what changes are needed to the below code?

      “visibility”: {
      “operator”: “?”,
      “operands”: [
      {
      “operator”: “==”,
      “operands”: [
      “[$_ModerationStatus]”,
      “Pending”
      ]
      },
      “visible”,
      “hidden”
      ]
      }

      Answer from the forum: This is happening because of recent change in JSON schema to officially support Approval Status column in JSON formatting.

      Due to this update, the @currentField and [$_ModerationStatus] will resolve to internal code (enum value) and @currentField.displayValue and [$_ModerationStatus.displayValue] will resolve to the localized string (I guess according to language).

      Post link:
      https://techcommunity.microsoft.com/t5/sharepoint/json-format-broken/m-p/2968990/highlight/false#M55139

    • Here is a post from GitHub detailing how this happened. Microsoft added a new feature which broke JSON formatting for the Approval Status filed…. thanks MS!

      https://github.com/SharePoint/sp-dev-docs/issues/7513

    • Hi All,

      with the help of some nice people from the Microsoft SharePoint forum (@ganeshsanap & @Danie365), I have a fix that I have tested and is working for me. Please test yourselves.

      Replace:
      “visibility”: {
      “operator”: “?”,
      “operands”: [
      {
      “operator”: “==”,
      “operands”: [
      “[$_ModerationStatus]”,
      “Pending”
      ]
      },
      “visible”,
      “hidden”
      ]
      }

      With this:
      “visibility”: “=if([$_ModerationStatus.displayValue] == ‘Pending’, ‘visible’, ‘hidden’)”

  • Hi WonderLaura, this is immensely helpful!
    Is it possible to amend the button to open the Edit form for that item? That would save my users a lot of pain…
    Thanks
    Nick

    • To create a button to edit an item, you would use a hyperlink action instead of a flow action, and the path is the list URL with editform.aspx?ID=
      and then after the =, that’s where you would need it to have the ID of that list item. I’ve never done it, but that seems like it would be the way.

  • Laura, Great site! Is it possible to have a column value trigger a value inside of another column in the Same Lists page. Ex; choosing a value of -“Patient Ready” in column 1 , trigger a value of a “Time stamp” in column 2. thanks

  • Thank you so much for the tutorials. I noticed that if you enable the Document ID Service Site collection feature, you can fetch the listItemId guid always in the itemurl. So this works for all views and all doc libraries

  • Thanks for the informative post.
    How do you pass the item Id to the flow?

  • I’m very new to this and have no coding background. So i have copied the code and pasted in the column settings and it states to “Please enter valid column-formatting JSON.” and the preview or save buttons are not available.

  • It’s very easy to create a trigger button right there on a share point with the help of your blog information. Very informative information.

    Thank you

  • Hi, is it possible to create a trigger when a new term group/set is added to my term store in Sharepoint? I would need it to have it updated in an excel list.

    Thank you!

  • This works great! Just have a question. Is there a workaround for the button to also show when you share the SharePoint item link url? When the user click on the link it opens the item preview pane, it shows the column but the value is null. If you click in the value no flow triggers off.

    • Hi Malinda, I’m not sure. There may potentially be a JSON way, but I’m not sure. Click to open a new list item, and click the little “edit form” button at the top right. There’s a way to put JSON code in there, or you could just hide the column from the form itself.

  • Hi Laura. I have been using the JSON trigger in Sharepoint for a few years for an approvals flow (thanks). Curiously it has stopped working around mid-December 2021 I think, I can’t figure out what is wrong. I have tried SaveAs the Power Automate and setting up a new identity but that hasn’t solved the problem.

    In Sharepoint List > The button seems to work, the flow dialogue in SP comes up as normal, when I click the “Run Flow” button, it appears to work. However, the flow itself is not running, suggesting maybe this is a Power Automate issue rather than SharePoint.

    I guess the flow trigger isn’t triggering, it is “For a Selected Item (in SP)” > “Get Item” using the ID parsed from SharePoint. The trigger seems sound and hasn’t changed, so I am lost regarding what the problem is.

  • Hi Laura, I have solved my own question (still being moderated). I discovered that by deleting the Sharepoint trigger “For a Selected Item” in the Power Automate script and then setting it up afresh, solved the problem. That is, just add new action and do exactly the same thing – go figure.

  • Relly hepfull post. Thanks
    I want to show the button if the Item has attachments only, but isn´t working. Do you know if it is possible

    “operands”: [
    {
    “operator”: “==”,
    “operands”: [
    “[$Attachments]”,
    “1”
    ]

  • Hello WonderLaura. This is an awesome solution and I have it running smoothly for my use case. Thank you so much for posting this! The one question I have, is it possible to do an OR in the JSON to handle different status’ for the button to display? So for example if status equals Pending OR Rejected the button displays.

  • Hi Laura,

    Is there a way to disable the button after one click so it can only be triggered once?

    • No, there isn’t a way to disable it. You could just use logic based on some other field value, to hide it. But users could always still trigger it using the Power Automate option in the toolbar menu at the top of the list/library

  • I have this set up in my list as a button and when I click the button it just says “setting up” with the loading circle and nothing ever happens.

    The flow work when I trigger it from power automate, but not from SP List

  • Hi Laura,

    I am using the condition to show the button based on the value of another column.

    Is it possible to use an “OR” statement so that if the column value equals either “NO” or “” (blank) then the button will show? Otherwise if “Yes” then it won’t show.

    Thanks,
    Chris

    • Probably, but I’m not sure what the syntax is for logic like that. It’s all written in JSON.

    • I’m on pace with you @sudosaurus, piecing out how to make this button conditional on other columns so that it can vanish upon running the flow once, or upon another condition.

      Skyler, this is probably because you haven’t automated your flow from the list by clicking the “integrate” and then “Automate” buttons. I’ve made the same mistake. Doing this generates a List ID. The JSON in the button column requires both the Flow GUID and a List ID to run the flow. You spin forever because your Flow GUID is good, but it’s looking for the List ID. Perhaps it’s a function MS needs to look at to warn users they don’t have a proper List ID.

    • Hi Laua,

      I managed to figure it out with persistance! 😉

      “visibility”: “=if([$SentToCx] == ‘Failed’,’visible’,if([$SentToCx] == ‘No’,’visible’,’hidden’)”,

  • Good morning Laura,

    I have this working in a list perfectly but it doesn’t seem to work with the list as a web part. Do you have any idea why? I’m using it b/c the tool I built has 3 flows and the last one is to be manually triggered. I built a dashboard that shows Pending Reviews by status and thus I am using the list in various views on a page. And of course you don’t get the drop down on the top bar either of the list in a web part.

  • Chris,

    YOU ROCK my friend.

  • Great post. Thank you very much.
    Quick question, can the button be press by a user with view access to the library?

    Appreciate it.

  • Hi Laura, I am facing some issues – while formatting the column, I am at the advanced mode, entered the code as above but get an error: Please enter valid column-formatting JSON. Any idea what am I doing wrong? Thank you

  • Hello. I had a question, must the bot owner have access to the Sharepoint site?

    • Bot? I haven’t mentioned bots at all in this post, but for a flow, yes the person creating it should have access to the data.

  • Thank you Laura for a really easy to understand and simple to deploy page. Chapeau! One question is I would like to do is only show this button in the “drafts” folder as there is no operator similar to @contains. Is there a way to show/hide the button on folder name or ID please? Once again thank you for excellent explanations and code.

  • Hi Laura, amazing post – thank you!

    Is there any way to add a filter to the above so that the button only appears for files within a library rather than against all folders as well?

    Many thanks,

    Chris

    • There’s a piece of metadata called IsFolder, and it is a boolean. Maybe you could add to your code that IsFolder is false. I’ve never done it, but theoretically it could work.

  • Hi Laura – I have tried creating a button and it doesn’t show in my SP library column no matter what I try. I have reviewed all these comments and tried various things, including completely retyping the code, and still nothing shows. I don’t get an error, there is just nothing in the column. It seems there have been several MS updates affecting this. My content approver shows “Draft” not “Pending Approval”, so I updated that. Somebody mentioned that we need to include the schema info, and I have. I can’t see anything else, but I’m new to JSON, basically I understand the coding but not enough to troubleshoot it.

    Here is my code:
    {
    “$schema”:”https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
    “elmType”:”button”,
    “txtContent”:”Publish”,
    “customRowAction”:{
    “action”:”executeFlow”,
    “actionParams”:”{\”id\”:\”d4b015a7-ba56-4af9-aa04-be3ce3583c3a\”}”
    },
    “style”:{
    “background-color”:”purple”,
    “color”:”white”,
    “visibility”:{
    “operator”:”?”,
    “operands”:[
    {
    “operator”:”==”,
    operands:[
    “[$_ModerationStatus]”,
    “Draft”
    ]
    },
    “visible”,
    “hidden”
    ]
    }
    }
    }

    Any ideas? GraemeNZ

    • I’m sorry but I have no idea how to troubleshoot JSON code.

    • Graeme, you are missing your tenant ID in front of your flow ID in your actionParams it should look something like this:

      “action”: “executeFlow”,
      “actionParams”: “{\”id\”: \”v1/d1b055db-44e9-493c-b2a7-9fc038dxxxx/fd3aa049-158b-4232-8b7b-4a1f085exxxx\”}”

      You need to click “Integrate” and “Power Automate” in your list. From there go to your flows and copy the ID, that will provide your tenant ID with your flow ID in the proper syntax.

    • Graeme, you are missing your tenant ID in front of your flow ID in your actionParams it should look something like this:

      “action”: “executeFlow”,
      “actionParams”: “{\”id\”: \”v1/d1b055db-44e9-493c-b2a7-9fc038dxxxx/fd3aa049-158b-4232-8b7b-4a1f085exxxx\”}”

      You need to click “Integrate” and “Power Automate” in your list. From there go to your flows and copy the ID, that will provide your tenant ID with your flow ID in the proper syntax.

  • To be more specific:
    Integrate>Power Automate>Select your desired flow>Export>Get flow identifier

    • Hi Steve – Is that not what I’ve got on the 6th and 7th lines?

      “action”:”executeFlow”,
      “actionParams”:”{\”id\”:\”d4b015a7-ba56-4af9-aa04-be3ce3583c3a\”}”
      }

      I had a chat with our friendly IT professional. To get this button to display he had to significantly change the button style attributes. He also used the ‘display’ attribute with a more familiar IF formula instead of the operator/operands statements which Laura showed us… I suspect this is the code which which was preventing the button from showing in the 2022 O365 environment.

      },
      “style”:{
      “border”:”light”,
      “display”:”=if([$_ModerationStatus] == ‘Approved’ , ‘none’, ”)”,
      “margin”:”5px”,
      “border-radius”:”5px”,
      “text-align”:”center”,
      “color”:”white”,
      “background-color”:”green”,
      “cursor”:”pointer”},

      Hopefully this helps others out there.
      GraemeNZ.

    • Hi Graeme,

      You only have your Flow ID, and not the full ID that includes your client ID. I realise Laura’s post doesn’t cover this part really, as she is likely not in the same kind of tenant environment.

      1. Go to your desired flow
      2. Click on the ellipsis (three dots)
      3. Click Export
      4. “Get flow identifier”

      JSON is great that way, you can use abstract syntax or excel-style expressions, or a combination. I also much prefer the excel-style, as that’s what I’m used to. You are using operators in your statement “==”, you can throw in OR and AND statements too with || and +

      “style”: {
      “background-color”: “navy”,
      “color”: “white”,
      “visibility”: “=if([$Status] == ‘Received’ || [$Status] == ‘On Hold’, ‘visible’, ‘hidden’)”
      }

  • Hi Laura, This solution is Awesome. I would like to display the button(Get Approved) only when an item from the list is selected. How can I achieve this?

    • I don’t think there’s a way to make a button know if that current row is selected.

    • Sumanth, there isn’t a way to do that. Either you have to make the button visibility conditional on something, or have it there all the time. You could create a custom Edit Form in PowerApps that would make the button only visible in Edit Mode vs Display mode.

  • Hi Laura, or anyone else reading this. I need to make my button display if two conditions exist for Operands. If field A = ABC and field B = Y how can I do more than one operand in this scenario?

    • I’m not sure. I don’t know JSON very well.

    • “visibility”: “=if([$FieldA] == ‘ABC’ + [$FieldB] == ‘Y’, ‘visible’, ‘hidden’)”

      This will make your button visible only if BOTH conditions are true, so be aware of that condition 🙂

    • I find it much easier to the excel-style logic for the strict abstract syntax for the operands, you can then fit your conditions in much tidier code and don’t have to deal with all the spacing/line breaks, etc…

    • Thank you @Steve, worked perfectly except I needed to use && instead of the “+”
      Final result that worked was: “visibility”: “=if([$FieldA] == ‘Notification Sent’ && [$FieldB] == ‘Y’, ‘visible’, ‘hidden’)”

      And while I was waiting for a reply, I did come up with a work-around using the operand.
      I created a calculated column varShowReviseBtn to display the two columns I was comparing and use that as the output in the string, it looked like this:

      “visibility”: {
      “operator”: “?”,
      “operands”: [
      {
      “operator”: “==”,
      “operands”: [
      “[$varShowReviseBtn]”,
      “Notification SentY”
      ]
      },
      “visible”,
      “hidden”

      But they way you shared is more efficient, without the need to create additional columns. Thank you for the quick response!

  • Right! My bad @Chantel B., I used the wrong syntax for “AND” and put “plus”, sorry about that. I much prefer the excel-style logic as it makes more sense to me, and saves soooo much more space in the code.

  • Hi Laura, tx for your excellent (& popular) post about to tirgger a Power Automat flow for a selected file. Using your examples we’re able to add buttons. We do have an extra challenge: we have site collection w/ multiple libraries 10+ and want to apply a button that triggers the same flow from within each library. Unfortuanately the Power Automation ‘For a selected file’ requires 2 parameters to be defined: “Site Address” & “Library Name”. Is there a possibility to include the library name/id as parameter when triggering the flow via the button, as such we would only need to implement one flow and call that same flow from within any library?

  • Laura, what would you do if you just wanted it to be a button on a page instead of in a list. I’ve implemented a flow that pulls data from a list based on a filter and populates a word document. I made a flow for each division. Buttons as you know require a URL. I have extracted the workflow ID.

    • When you have a flow that’s manually triggered, share it with someone as a run-only user. Then, it will send that person an email. Get the hyperlink out of that email.

  • Pingback: BUTTON IN SHAREPOINT LIST TO TRIGGER POWER AUTOMATE – a few tweaks  – Matt Kirby

  • Pingback: Action Button in Lists: Set Column Value | @WonderLaura

  • Hey Laura. Love this post. Do you know of anyway to pass the SP list item ID to the Flow and what Trigger or Action would capture it? I’ve searched around and can’t find an answer, or maybe I’m not using the correct search terms. 😊

    Thank you. 👍

  • Hi Laura, read this year’s ago and came back as I am doing something more complex with it now. I will definitely use your new and improved solution too but cannot leave a comment on that page 😁
    I have a new question. Putting a “=if” statement in each JSON attribute starts to get unwieldy because the syntax is laborious with all the escaped quotes and single quotes, and because I basically have the same if conditions in LOTS of individual attributes and thaat really goes against the grain because
    1. it’s ugly
    2. it’s inefficient to keep evaluating the same condition
    3. It’s hard to maintain, because if I change one of the values that I am inspecting, then I hjave to change it in EVERY condition.

    Is there a way to put whole JSON blocks in a single if statement like this

    …[JSON PREAMBLE AND OTHER BITS OF FORMATTING]
    =if(([$STATUS] == ‘New’),
    {“elmType”: “button:,
    [ALL MY FORMATTING CODE FOR MY SUBMIT BUTTON]},
    {“elmType”: “button:,
    [ALL MY FORMATTING CODE FOR MY CANCEL BUTTON]})

    ???

    Oh, and if anyone knows a JSON editor that lets me add “comments” to my source code JSON but then outpiuts it without them (as they arenot valid json) That would be great

  • Hi Laura,

    Is there a way to only make the button appear for certain users?

  • Hi Laura,
    First of all thank you for such detailed information on the button control. I just need one help from you. I am trying to display an error message if the Issue is not assigned and the flow should not initiate. Your help is highly appreciated.

    here is the code snippet.
    ________________________________________________________
    {
    “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
    “elmType”: “Button”,
    “txtContent”: “Submit”,
    “customRowAction”: {
    “action”: “executeFlow”,
    “actionParams”: “{\”id\”: \”1e8e46e7-06a0-4f68-8fcb-680dcdb7c023\”}”
    },
    “style”: {
    “visibility”: {
    “operator”: “?”,
    “operands”: [
    {
    “operator”: “==”,
    “operands”: [
    “[$AssignmentFlag]”,
    “”
    ]
    },
    “”,
    “hidden”
    ]
    }
    }
    }
    ________________________________________________________________

    Thanks in advance.

    • Sorry, I don’t know much about how to write logic in JSON.

    • You are missing your tenant ID in front of your flow ID in your actionParams it should look something like this:

      “action”: “executeFlow”,
      “actionParams”: “{\”id\”: \”v1/d1b055db-44e9-493c-b2a7-9fc038dxxxx/fd3aa049-158b-4232-8b7b-4a1f085exxxx\”}”

  • Hi Laura, this is great – exactly what I needed!!

    However I’m having trouble with the “But wait, there’s more!” section.

    When I add this expression “sub(int(triggerOutputs()?[‘body/{VersionNumber}’]),1)”, power automate tells me it is an invalid expression. I followed all your steps exactly, so I’m not sure why it is incorrect?

    Let me know, thanks!!

  • Hi Laura, tx for sharing very valuable examples 👍🙂💪 of how to implement a button or link to run a flow from within a SharePoint List or Library. I was able to trigger a flow using a link in a regular view. However when displying that same view using a ‘List’ web part on a SharePoint page, the link is not triggering the flow. Did you ever manage to trigger a flow while displaying the view in a List web part? Tx.

  • JSON functions require that columns are visible in a view. Displaying a list through a web part isn’t the same as being in the list. As soon as you click on any actionable item in the web part displaying the list, it navigates you to the list itself. No matter what you do, to get the button to work it would be a two-step process to get to the list itself, where the button works.

  • Pingback: Single On Demand Power Automate Approval Flow For All SharePoint Document Libraries – Part 1  – Power Platform Puzzles

  • Hi Laura, Thank you for this! I have a weird situation. I am trying to implement the new way you suggested ( where the button changes a value rather than launches the flow) while keeping the style of the button and the visibility. When I change the custom row action to ‘setvalue’, instead of ‘executeflow’, I lose the style and visibility functions. In other words, when the custom row action is set to to flow, the button is blue and only appears when Column X has a specific value. When I change the action to setvalue, the button is gray and is always visible. The former style is my goal.

  • Joana Villas-Boas

    Hi Laura, great article but I am also struggling to make my button Show in my Gallery view. It shows on the list view and works fine, but on the gallery view it’s just “-” that dosent work.

  • Vikki Middleton

    Hi Laura, thank you so much for this post – it is a great help.
    However, I am getting very frustrated with mine! The flow is based on a selected item for my SharePoint library, the button is applied and set to only show when the status column is ‘Draft’. This part works brilliant.
    The issue I am having is if I select the button to run the flow, it is running the flow for ALL items rather than just the one, I am not selecting the item first because I know users won’t, so my question is, do you know of a way to stop the flow running on pressing the button UNLESS the file is selected.
    Or maybe only show the button when a file is selected, as well as the above condition?
    Your help will be greatly received!
    Thanks
    Vikki

    • In your flow, be sure that you’re using the “for a selected item in SharePoint” trigger, and if you have a loop somewhere in your flow that is iterating through all the items in the library, that would be the culprit, which is not related to the button and clicking it.

    • Vikki, if you scroll up and read some of the previous posts, you can see some info on how to build conditions on making the button visible or not. Personally, I found it easier to implement a two-step method where users have to edit the column to make the button visible (I used a checkbox Yes/No column) and then run the flow with the “For a selected item” trigger.

      Also, Laura is correct about your flow. If it’s running through all items then you’re likely not using the right trigger or Approvals operation (if that’s what your flow is using).

  • Pingback: Przycisk na liście Sharepoint Online do wyzwalania przepływów Power Automate | Strzezek

  • Daniela Farrera

    Hi Laura! I love the simple and elegant solution. I just have the following problem: My flow is located inside a solution in a different environment that the Default one. What do you recommend in this particular case?
    Thanks in advance!

    • I’m not sure, I’ve never tried that.

    • Daniela Farrera

      I solved it as follows: The first section after de v1 is the environment ID and after the / is the ID of the flow

      Ex. “actionParams”:”{\”id\”: \”v1/12345678-1234-1234-1234-123456789012/12345678-1234-1234-1234-123456789012\”}”}

  • Hi. Great post and exactly what I need. It’s working fine but I need to only show the button if one of two particular column status is present. So am looking for the JSON code for some kind of OR statement. I see above in the comments a similar question but that was an AND statement. Anyone know how to check for one of two conditions? Thanks

  • Hi Laura, your solution is excellent. I have a slightly different problem:
    The button works just fine for PC users (i.e. users using a desktop browser), but for mobile users it is a different case. When a user clicks on the button on his tablet, the item list form opens instead (as if he clicked on the item title).
    Is there a way via formatting to also show the button on this list form itself (now it is shown without any value)? That would save my day. The only way I found are by customizing the form with Power Apps, but this is not a option at the moment.
    BR

  • So awesome! Thank you so much! Didn’t know this was even possible until I cam across this post by accident. Once issue, though, in trying to trigger the flow from a list I found it more useful to have Get a Specific Item as my trigger.

    I picked that up from here: https://techcommunity.microsoft.com/t5/sharepoint/sharepoint-button-to-run-a-power-automate-flow/m-p/2249294

  • Hello, Laura. I’m trying to get this same functionality for the Classic Experience environment, but I’m told that JSON formatting does not work here. Looking for something in along the lines of Client Side Rendering to display a button on the list view to trigger a Power Automate flow. Any suggestions? Thanks in advance.

Leave a Reply