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

  • Hi Laura,

    Nicely done, but I have a couple of questions.
    1. Does the flow need to have already been shared with the SharePoint list that the flow is acting on?
    2. If yes, what minimum license level for Flow is needed to enable that?

    • 1. No
      2. This isn’t a particular Flow license level, I only have Office 365 E1.

    • Hi laura, If I add the list webpart on the modern page, the flow panel doesn’t opens up , while it is opening if I do the same thing by directly going on the list, Is this is the microsoft bug?

    • Maarten de Keijzer

      Hi Laura,
      Wonderful item, but unfortunately not what we’re looking for.
      Is there any method to create a ‘fixed’ button on a modern SharePoint site (page) to start a Flow that has been defined as a Manual triggered Flow (asking for some text input and a link to a document file)?

    • When you share a flow with someone as a run-only user, the email it sends has the link to directly trigger the flow, and then you can use that link on a button on your site or anywhere.

  • Hi Laura,
    Thanks for this blog, but as always it asks more questions 😉
    I would like to show a button when a document is published. This starts a Flow so that it makes a copy of the document and copies it to the correct language intranet. This flow works well.
    But I do not get the condition right in JSON.
    How do I get this done when Version ends with .0?
    Is this a solution or do I have to think about another way?
    Can you help me with this?
    thanks in advance

    • Rodney Rollock

      I’d be interested to learn more about this…I would like to trigger a flow that would convert a Word doc to pdf and add the pdf to a different list.

  • Hi can we update a column in sharepoint list on click of a button which we create using column formating

  • how to run a custom code using JSON button in SharePoint

  • None of these work when I paste them into my column formatting dialog. It says, “Please enter valid column-formatting JSON.”

    • If you copied and pasted then the quotes are most likely the wrong characters. Change all the double quotes to double quotes, i.e. ” not “ or

    • I also can’t get any of these to work when I paste them into my column formatting dialog. Even if I paste them into Notepad first for standard character formatting. What am I missing? I would really like to use this one for the button format, but it always gives “Please enter valid column-formatting JSON.”:

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

    • Try re-typing your quotation marks. I’ve seen those mess up when copying and pasting.

    • The basic button snippet has an extra right hand curly-brace too

    • copy the code and You have to edit “ –> ” then you will get rid of Error

    • I also had to remove the scheme line “$schema”: “https: //developer.microsoft.com/en-us/json-schemas/sp/column-formatting.schema.json”,

  • I need to start a Flow from a single button on a SharePoint page. The Flow has a “Manual” trigger. Can you please tell me how I can add it to the “onclick” attribute: <input type="Button" style="background-color:#a7cb00; width:250px;font-size:13pt" onclick="window.location=

  • In my last comment it looks like the blog software changed my quotes too. In any case, just use a normal double quotes. You have to replace them all.

  • Hi Laura, the URL for my Flow isn’t quite the same as yours, and I’m trying to parse out the GUID, and could use a little help: https://us.flow.microsoft.com/manage/environments/Default-60b81999-0b7f-412d-92a3-e17d8ae9e3e0/flows/bf454aa9-d6fe-4614-b790-6e2beb08c1f6?backUrl=%2Fflows%2Fbf454aa9-d6fe-4614-b790-6e2beb08c1f6%2Fdetails

    • Your GUID is everything after “/flows/” and before “?”, so: bf454aa9-d6fe-4614-b790-6e2beb08c1f6

  • Hi Laura,

    Good Day.

    I just want to ask a question about your post.

    Is the flow you created can be run by other user who had access to list? or is it only applicable to the owner of the flow itself?

    Thank you in advance.

    TinnyWinnie

  • Hi Laura,

    Thank you for the quick reply. 🙂
    This is great. I’ll try it on our side.

  • Hi Laura, I have been able to follow along the instructions with the addition of a button working well. What is not working for me though is the button only showing based on column status – I am not receiving any errors in the json code box its just the button doesn’t appear at all now after extending the code. Is there anything else I need to be aware of when using this? Thinking maybe the format of the column of the status or anything? I feel so close but yet so far to completing this work!!!

  • Hi Laura, will the option to show button after approval status has been met work on any other field in the SharePoint list or does it have to be the approval field? Sorry for the repeat query, just trying to get it to work!! 🙂

    • There’s a reference in the JSON to “current field” versus @fieldname. So if you want the logic to use the current field, use that, but if you’re referencing a different field, you have to use the ampersand. I don’t remember the exact syntax off the top of my head, but it’s definitely different.

  • How do you pass parameters? What is format?

  • Okay, I’m at a loss. I wrote the following code based on your example and it doesn’t seem to matter what I put in the ButtonVisible field, the button is always visible. I checked to make sure that it has the correct system column name. It does. I thought maybe Visible is a reserved word, so I replaced it with Yay/Nay. That didn’t work. I have no idea why it won’t execute correctly.

    {
    “elmType”: “button”,
    “txtContent”: “Mark Complete”,
    “customRowAction”: {
    “action”: “executeFlow”,
    “actionParams”: “{\”id\”:\”b9437ba0-a6a9-4a72-be9e-277f4604bbc1\”}”
    },
    “visibility”: {
    “operator”: “?”,
    “operands”: [
    {
    “operator”: “==”,
    “operands”: [
    “[$ButtonVisible]”,
    “Visible”
    ]
    },
    “visible”,
    “hidden”
    ]
    }
    }

    • Update: I figured out that if I add in the code that you added to change the text and background color, it works fine. I was a little worried about that, because I didn’t want a purple button. However, I figured out I can change it to light grey and it looks fine.

  • Hi,
    I have the buttons working in a list, pretty cool.
    And when the list is viewed on a modern page in a list view web part, the buttons do show.
    But they are not clickable.
    Any thoughts?

    • I have the same issue. Anybody know of a way to allow the buttons (or really, any of the additional tools) to work in a webpart without having to open the library?

    • Hopefully Microsoft will fix this little bug. I guess in the meantime we have to make the users do that one little extra click to get to the list / library.

  • I love finding posts like this. Thank you for the detail.

  • has anyone yet found a way of doing this with a calendar based list, so not modern view?

  • If only I’d come to this blog in the first place and found that my Flow had to have a custom trigger!! Every day’s a school day… :o)

  • Deviprasad Shetty

    Hi Laura,

    I am new Flow workflows and I am creating multilevel approval workflow. In SharePoint Designer workflow we have action Wait for Field change in Current Item. Do we have any similar action like this in Flow workflows.

    Thanks, and Regards,
    Deviprasad Shetty

  • Hello, this is a wonderful alternative to trigger flows in modern view! I have implemented it on one of my lists and it has been working just splendid! I have one small issue though that I can’t seem to figure out how to fix. When I am creating a new list item, even though I’ve hidden the ‘Action’ column in ‘Advanced Settings’ in the list settings, it’s not visible at first, however when I create a second list item, I see the action column in the form view. It seems like it’s being reset for some reason. Has anyone noticed any similar behavior and can assist with this issue?… Looking forward to a response…

  • So it seems. However, it leaves the field open to the user who is filling out the form. I guess I can input some custom JS to have it hidden all the time, but, I try to avoid such customization because of how specific the reasons are…
    Thank you for your response 😀

  • Hi Laura, this is a fantastic post, but I’m having the same problem: Please enter valid column-formatting JSON.
    I’ve changed all quote marks, but can’t see any other issue. What else could be wrong?

    • Here’s the code again, I just copied it straight from a formatted column in SharePoint:
      {
      “elmType”: “button”,
      “txtContent”: “Get Approved”,
      “customRowAction”: {
      “action”: “executeFlow”,
      “actionParams”: “{\”id\”: \”3fd1d970-0fea-496f-be53-5a8608b382ac\”}”
      },
      “style”: {
      “background-color”: “purple”,
      “color”: “white”,
      “visibility”: {
      “operator”: “?”,
      “operands”: [
      {
      “operator”: “==”,
      “operands”: [
      “[$_ModerationStatus]”,
      “Pending”
      ]
      },
      “visible”,
      “hidden”
      ]
      }
      }
      }

  • If another user clicks on the button, then opens a form and the flow does not start ??

  • ok everyone must have authority on the flow …

  • Hi Laura!
    This helped me out a lot! Thanks! I just have one question. Do you know of a way of hiding the button if the user is not authorized to run the flow. I.e. the user is not in the “run-only” list.

  • I had this working perfectly. Then suddenly, yesterday, any views that had any JSON formatting on any columns stopped displaying in “new Experience”. I’ve had to delete all those columns to make my data visible again, or I have to swap back to classic which means I can’t use the buttons any more
    I think MS have rolled out something that has broken this

    • I just looked at mine, and they’re still all there, just like I originally set them up. Not sure why yours did that. Same in all browsers?

  • Laura, Thanks so much for this! Since it’s possible to show/hide the button or link based on a column value, is it also possible to trigger two different Flows? So, let’s say there’s a status column with Approved/Rejected/Pending. If an item in Pending, I’d want to run a Flow called “Get Approval”; if it’s Rejected, I’d want to run another called “Submit Appeal”; and if it’s Approved, show nothing. I’m sure this is possible, but my skills (and patience) with json are lacking.

    • Yes, you can use Flow actions that trigger other flows. So, your button can trigger one Flow, and that Flow can have conditions in it, and each branch of the condition can have actions that start the other Flow(s). These are in the Flow category called ‘Flow Management’.

  • Can you hide the button for users who have no “run-only” access to the flow? Or maybe hide it from users lacking specific access to the list?

    • I can’t think of a way, but I don’t know that much about JSON. I know I could do it in a list of things (gallery) in PowerApps, but that’s totally different.

  • Hi Laura, thank you for the effort you put in teaching us these techniques. I have a question though.. Maybe you can advise.

    We have a “Document Manager” who is responsible for the documents listed in a library. So everyone else, except for the Document Manager, has read only permissions for the items. But the Flow button then disappears. So I came across this article and was hoping to have found the solution to maintain the permissions (read only) and have a button to trigger a specific Flow.

    But the button only works when the user has Any other permission than Read Only. Is there any other way to achieve this?

    • Well, that’s frustrating! It doesn’t surprise me. No, I don’t know of a way around that. Even when you add them as “run only” users of the Flow?

    • Yes even with Run Only user permissions. I continued my search and someone advised to give everyone full permission on site level and on library strip the permissions. That should be the workaround.

      But it’s too much hassle to do that now, I’d have to recheck all sites, libraries etc etc if the permissions are still set correctly.

    • OH right, that’s what had to be done in classic mode, too. So, not new.

  • Hey Laura, is it possible for the execute flow button to work on a folder/ document set? I want to update the metadata on a document set, but am unable to get the flow to trigger.

    • I can’t find a way to do that, but I think Document Sets are going to get more love from Microsoft in the coming months, so maybe they’ll add that.

  • Hi Laura

    It’s a very good post. It was very useful to me.
    I would like to ask you if it is possible to display two different buttons for different Flow in one column, depending on eg the status of the document?
    If the status of the document is “New”, then the “Send to approval” button should be displayed and to start some Flow.
    And if the status of the document is “Approved”, then the “Finish” button should be displayed and to start other Flow.
    And of course, for other statuses, nothing should appear in this column.

    Best regards
    Tomasz

    • Yes probably. I’ve never personally tried it, but I’m sure you could figure out the logic for that.

    • Mattias Sandberg

      Hi Tomasz!
      Yes it is possible. I have tried it with success. If you want only one button to be visible at a time then you will need to do though is to set the width of the first button to 0 in case the second button is visible. I have not made this in my test but it shouldn’t be a problem to add that as well.

      {
      “elmType”: “div”,
      “children”:[
      {
      “elmType”: “button”,
      “txtContent”: “Send for review”,
      “customRowAction”: {
      “action”: “executeFlow”,
      “actionParams”: “{\”id\”: \”FLOW GUID\”}”
      },
      “style”: {
      “background-color”: “#279bbf”,
      “color”: “white”,
      “border-radius”: “5px”,
      “margin-top”: “5px”,
      “padding”: “10px”,
      “cursor”: “pointer”,
      “visibility”: {
      “operator”: “?”,
      “operands”: [
      {
      “operator”: “!=”,
      “operands”: [
      “[$axApprovedVersion]”,
      “[$axCurrentVersion]”
      ]
      },
      “visible”,
      “hidden”
      ]
      }
      }
      },
      {
      “elmType”: “button”,
      “txtContent”: “Send for approval”,
      “customRowAction”: {
      “action”: “executeFlow”,
      “actionParams”: “{\”id\”: \”FLOW GUID\”}”
      },
      “style”: {
      “background-color”: “#279bbf”,
      “color”: “white”,
      “border-radius”: “5px”,
      “margin-top”: “5px”,
      “padding”: “10px”,
      “cursor”: “pointer”,
      “visibility”: {
      “operator”: “?”,
      “operands”: [
      {
      “operator”: “==”,
      “operands”: [
      “[$axApprovedVersion]”,
      “[$axCurrentVersion]”
      ]
      },
      “visible”,
      “hidden”
      ]
      }
      }
      }
      ]
      }

    • I’ve done something similar and it worked fine. Just be aware that in your example if the flow triggered by the “Send to approval” button changes the status of the document from “New” to “Approved”, then the user would need to refresh the page in between triggering the first flow and the second flow. This would make things pretty clunky and there is no current workaround for that.

    • Just extending the reply from Mattias – you can use the following styles properties to ensure the varying buttons being displayed appear inline with each other:

      “position”:”absolute”,
      “left”:”0″,

      Hope that helps someone.
      p.s. Laura – great post by the way!

  • As of the update on 3/27/19: When you evaluate the _ModerationStatus column it returns blank instead of “Pending”, “Approved”, or “Rejected”. This makes conditional formatting using the _ModerationStatus column impossible as far as I know. The workaround I used is to create another column that tracks approval status and use that for the conditional formatting of the button.

    • I don’t know if it’s applicable to this situation, but I was recently able to use the built-in moderation status column in a Get Items action filter in a Flow by using OData__ModerationStatus for the column name (note there are two underscores). Also, the values for the column aren’t Pending, Approved, Rejected, etc.; they’re numerical:

      # Status
      0 Approved
      1 Rejected
      2 Pending
      3 Draft
      4 Scheduled

  • Hi Laura, Just came across this post. Thanks for putting the effort into putting this together and sharing it. It was very helpful. Like other users I’ve been testing some things and two things I’m trying to figure out. One is that when you click on the button it brings up the “Run Flow” dialog making you click one more time to run the flow. Is there a way around this? The flow is triggered on “For a selected item”. The other thing is that I would like to make it so most users have read only access to the list but can run the flow. The test user has “Edit” access to the O365 group the list is in and “Read” access to the list itself. Even though I have the user added to the “Run Only” users group on the flow, it will not run the flow. Clicking on the button does nothing. Any suggestions?

  • Hi

    Thank you very much for your article. Everything works really great!

    I have a question concerning visibility: is it possible to make the visibility dependent on two other colums? – E.g.: If the approval Status is “pending” and Customer Status is “active” the button shall be visible.

    Thank you
    Peter

    • @Peter, indeed it is possible. I had a similar requirement and it took a while figuring it out but hopefully this helps you, and others. What you need to do is clear out the entire “visibility”: {…} section from Laura’s example and replace with something like this (I’ve guessed your internal columns names as approval Status = ‘ApprovalStatus’ and Customer Status = ‘CustomerStatus’):

      “visibility”: “=if([$ApprovalStatus] == ‘pending’ && [$CustomerStatus] == ‘active’, ‘visible’,’hidden’)”

      I’d appreciate it if you (and anyone else) could let me know if this has helped you.

    • Joe, How would you change the 2 conditions if you need both fields to not be blank?

  • Hi Laura, this is still the best flow article out there.
    Do you know if it’s possible to actually run the flow when user clicks the button instead of opening the “Run flow” form? In cases when there’s no user input required, we just want flow to run right away.

  • Does anyone know why the column format tells me that the json is not correct ?? Do you have a right json?

    • If you copied and pasted the code from this post, you need to change the quotes (“) because what gets pasted from your copy is not a standard quote.

  • Hi Laura – this post opened my eyes. If I want to use the button to send an email, containing values from that particular row where I clicked the button, how would I do that? Right now, when I click the button, with the code you provided, an email is sent per row, from the sharepoint list. The possibilities though….. 🙂

  • Hi Mam,

    Thank you very much for writing such a great article, i am able to create the same in my development environment.

    just a simple question from my side, is there any Limitation for this button like it won’t work into the List view web-part?

    Issue i am facing right now is Button click does not Triggers the Flow from the web-part as it Triggers inside the SharePoint list.

    Please share your thoughts on it.

    • Nikhil, Did you ever figure this out? I am facing the same challenge that the button won’t initiate the Flow pop-out screen when exposed as a Web Part in a page.

    • This is a known bug that Microsoft is working on.

  • Hi Laura,

    Thanks for the post! Can i run multiple flows at a given time using this method? The trigger of my flow is for a selected item and the out of the box method only lets you run one running flow at a time (madness Microsoft!)…

    • No, unfortunately, it doesn’t work the same way out-of-box. You’d have to do something extra like my post on creating a button in a list/library to run a flow, with conditional formatting so it doesn’t show if already running based on some status field you create.

  • This really helped me out and was super easy to understand and follow – thanks so much!

  • Monica.villanueva@glogic.com.co

    Esto solo funciona para ejecutar un flujo de Flow, de designer no?

  • Hi Laura, We have a classic SharePoint workflow which automatically gets an associated List Column to show the status of the workflow (“In Progress” or “Approved”, etc.) as it should.

    The issue is trying to get the value from that workflow column within our Column Formatting code.

    In your example you used the value from “[$_ModerationStatus]” to decide whether or not to show/hide the button, but seems as though I can’t do this when trying to reference the workflow column. I’m using the internal name of the column but doesn’t seem to get the value.

    Using PnP PowerShell I can get the value. “Approved” is equal to 16.

    Do you know if it’s possible to get this value (“Approved” or 16 – any value would be good enough), when using Column Formatting and a workflow generated column? That way I can only show my button when the workflow isn’t In Progress.

    • Sorry I’m not sure, I’ve never tried that. I would probably be poking around just like you, trying different things like “16”. There’s some other weird way I’ve seen that column formatted, like #!;Approved or something with weird characters in it like that.

  • Another great tutorial. I have a couple of questions.

    1. How do I bypass the comment bit when clicked on the button so the flow just starts without the user knowing
    2. Is it possible to bypass the Flow and change the value of another field from Pending to Approved (without Flow)?

    • 1. Open up your Flow (flow.microsoft.com) and look at your trigger. Remove any “inputs” there. 2. Maybe with a calculated column?

  • Laura, I am interested in triggering a PowerApp (not flow) in the same manner. I would then like to use the PowerApp to manipulate the metadata on a document. Can you launch a PowerApp in a similar way and pass a handle to the document.

  • Hello, I’m trying to have the button disappear after the button’s been clicked, but I’m not sure how to do that, do you think you could assist me? Also, I’m not sure what I should be replacing ‘moderation status’ with for my column.

    • I ended up designing a gallery in PowerApps with buttons.

    • To make it disappear after it’s been clicked, you’d have to use logic. So, when I run the Flow, the flow sets a certain status field value in the list, and then the button is only showing if the status is “not started”. Moderation Status is the build in field name (system name) for the out-of-box content approval column. (Content approval setting is in the list’s versioning settings screen).

  • Hi there, is it possible to hide the button based on the filetype? What I want to do is have different flows based on pdf, doc, xls, and even hide if it’s a folder. Can’t seem to find the internal column name for that.

  • Mattias Sandberg

    Hi!
    I have a problem regarding lanuage settings and the column [_ModerationStatus]. When formatting this column depending on it’s contents the language setting is an issue. Therefore the user browser language settings will make the column formatting fail. I would need to access the internal value for this column to make the formatting work in any language. Is there a way of accessing this value? I have tried the following: [_ModerationStatus.value] and [_ModerationStatus.id] unfortunately without any success.

  • Hi, great post! But I’ve bumped into problem running flow mapped in button.
    One of the first steps of flow is to get items from this document library where button is placed. I’m starting flow as my user who is owner of flow and connectors are up-to date. Error in flow:
    InvalidTemplate. Unable to process template language expressions in action ‘Get_folder_metadata_using_path’ inputs at line ‘1’ and column ‘2028’: ‘The template language expression ‘json(decodeBase64(triggerOutputs().headers[‘X-MS-APIM-Tokens’]))[‘$connections’][‘shared_sharepointonline_1’][‘connectionId’]’ cannot be evaluated because property ‘X-MS-APIM-Tokens’ doesn’t exist, available properties are ‘Connection, Accept, Accept-Encoding, Accept-Language, Host, Referer, User-Agent, sec-fetch-mode, origin, sec-fetch-site, Content-Length, Content-Type’. Please see https://aka.ms/logicexpressions for usage details.’.

    I’ve noticed that issue is connected to token handling. Seems like button is not providing user token to flow. Is it possible to pass some additional info from button to flow? Maybe something changed in platform itself.

    Thanks

    • Solved! I’ve skanned your video with my colleague and problem was that we used Flows Manual button trigger not ‘For a selected item’ now it works and tokens are passed! Again awesome post!

  • Is it possible to use this steps on Task lists? I tried it and it is not working

    • “use this steps on task lists”? You mean put a button on a task list? Only if it’s a modern list. I don’t recommend using the “task” list template anymore.

    • Hi Laura – Given that you don’t recommend using the “task” list template anymore, are you able to recommend what to use instead?

    • I usually use just a custom list. In the list settings, you can click to add site columns, and quickly add other columns like due date, status, etc.

  • Hello,
    This is very useful.
    Can you please let me know if it is possible to pass a value to the Flow which is being triggered from the List. I would need to know and use the List item in the Flow on which the button has been clicked on.
    Many thanks.

  • Hi Laura, is it possible for the execute flow button to work on a folder , i am unable to get flow to trigger on Folder Button .

    • Ooh that’s a good question. I don’t know the answer to that. I’d try the “selected item” trigger and the “selected file” trigger, and maybe one or the other of those will work on a folder, not sure which one you already tried.

  • Hello Laura,

    I followed the instructions and it did work pretty fine for my user. However when my team members clicks on the button, the Flow window comes up, but doesn’t load any information so they can execute the flow for that item.

    The users were added as Run only users, and didn’t work. I have also added the users as Owners, also same issue.

    Couldn’t find anywhere to check on other permissions.

    Regards.

    • Does the flow work for them when they trigger it the regular way, not with this special button? If so, then the problem is not in the button.

    • Hello Laura,

      Yes the flow works in the regylar way. I have also tried using different scripts (found over the internet), and same issue occurs.

    • Wow, that’s odd, I haven’t seen that happen. Have you tried it out on various browsers, to see if the results are different?

  • I created a button in a column so then when people click it, they can activate a flow that sends an email. Everything works for me (as the owner of the flow) but I realized, will it work for other people who are editors/owners of the SharePoint site to run the flow too? Or is there a special feature Microsoft requires me to pay for?

  • I have used this in multiple SP sites but recently a user showed me that if we Search a list, we can’t kick off a Flow from an item in the search results even though the link is visible (nothing happens when clicked). The Flow button (in the toolbar area, if that’s the right term for it) is also missing if we do a search. Yet if we Sort or Filter, both work fine.

    So our current work-around is to search, edit a field (to update the Modified date) and then go back to the same view and Sort the Modified column to show Newest on top. Then we can run the Flow.

    Does anyone know if there is a better way to handle this?

  • Thanks Laura, This is valuable stuff. I too has the problems with quotes from your text (“ ” need to be “).

    I cannot make it work when I use the List Webpart on a page I created. Pressing the button simply does nothing. Any ideas on how to make this work.

    I modified it so the button text and action would change depending on a field in the list. I also used a different notation for the conditional statements (I forgot my reverse-Polish). Here format button column code (FYI):

    {
    “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
    “elmType”: “button”,
    “txtContent”: “=if([$NDA_x0020_Required]==’Yes’,’Request NDA Document’,’Get Document’)”,
    “customRowAction”: {
    “action”: “executeFlow”,
    “actionParams”: “=if([$NDA_x0020_Required]==’Yes’,'{\”id\”:\”e7a66c04-XXXX-409c-914b-036a6e27204a\”}’,'{\”id\”:\”bc17bfa5-XXXX-4b6a-b71d-3731b866117a\”}’)”
    },
    “style”: {
    “background-color”: “green”,
    “color”: “white”
    }
    }

    • @ Kevin Lynch, I discovered the same thing recently. There is a Uservoice idea for Microsoft to make Flow available inside webparts, but that was as far as I got!

      https://sharepoint.uservoice.com/forums/329214-sites-and-collaboration/suggestions/36709321-abilty-to-run-flow-from-library-list-webpart

    • Mattias Sandberg

      I would also really need to be able to build solutions where you can run Flows from webparts and also from search results, which is also not possible today for some reason.

    • When you create a manually triggered Flow, when you add someone as a “run only” user, it sends them an email with a link to trigger the Flow. Take this link, and put it as a hyperlink in a web part as a button.

    • Hey Laura,
      I also have the need to use my list with buttons in a List web part on a modern page. After following your advice, I did get an email to run the Flow with a “Get Button” button. However, since I want to allow the use of the buttons per list item, I am trying to figure out how would this work if the “Get Button” hyperlink exists as a single button on the web part… How is it going to target particular list items?

    • Not sure what you mean. This whole solution *is* based on the flow triggering per list item. It lists as a button per row of the list, as you can see in the screenshots.

    • Hi Kevin Lynch,
      I want to do something similar with the part of your code:

      “actionParams”: “=if([$NDA_x0020_Required]==’Yes’,'{\”id\”:\”e7a66c04-XXXX-409c-914b-036a6e27204a\”}’,'{\”id\”:\”bc17bfa5-XXXX-4b6a-b71d-3731b866117a\”}’)”

      I would like to, if the value of the field is “Yes”, do nothing (button is clicked and nothing happens) and if the value of the field is no, or has no value (empty), run the Flow. I have very little experience in JSON but have everything working how i want it to except for this. Any help would be greatly appreciated!!

  • Thank you. Works perfect!

  • I have a problem with displaying values from columns that are not present in the current view. Is there something I have missed or is it not possible? I would like to configure one column to show values from several columns including a button to improve the user experience. I can build it and it works fine until I remove the other columns from the view.

  • Hello Laura, a great video, actually I want to ask you something, I have folders, subfolders, and documents in the subfolders, Can you share a way to create a view like that one that you have that gives me the number of documents that i have there.
    For Example: Main view
    Emea > Dicember > 2019> 7 files 7 files
    US > October > 2019> 3 files 3 files

    • Hi Felipe!
      There is already a column for that so you shouldn’t need any formatting. It is called “Item Child Count”.

  • Laura, Love the button. Stumbled on your elegant approach when trying to figure out something else. Namely the ability to launch a flow when the user searches for a record in the list as opposed to manually scrolly down to the find the record that they want to launch flow for. Flow option goes away on the menu when you get your search results. Your button works great for us, but apparently whatever turns it off for the menu when you go to the search result, it also turns off the functionality for your button launch the flow. Any insight on your part? Thanks,

    • No, I’m not sure about that one. We’ll see if they make any announcements this week at Ignite, that would indicate a smoother experience between the list custom columns and search results.

  • This button is really great. The users love it. How can the code be tweaked so that the button is visible if the field is Pending OR Rejected? I tried to play around in JSON but couldn’t get anything to work :/

  • Ended up finding a solution that helped me:
    (Resource: https://techcommunity.microsoft.com/t5/SharePoint/Conditional-JSON-formatting-of-button-in-SharePoint-List/m-p/464400)

    {
    “elmType”: “button”,
    “txtContent”: “Submit for Sign-off”,
    “customRowAction”: {
    “action”: “executeFlow”,
    “actionParams”: “{\”id\”: \”987789d81-9008-4d2c-9833-74feff459a20\”}”
    },
    “style”: {
    “background-color”: “#0070c0”,
    “color”: “white”,
    “visibility”: “=if(([$Sign_x002d_off_x0020_status] == ‘Pending’)||([$Sign_x002d_off_x0020_status] == ‘Rejected’),’visible’,’hidden’)”
    }
    }

  • Hi Laura, I’ve been using this setup for a while but recently the button has stopped working. I am no longer seeing the pop-up on the right hand side to trigger the flow. Has anything changed on the SP Online side that might have broken this functionality?

    • I don’t know, I recommend testing the flow by triggering it some other way. Mine in my environment still works fine.

    • Make sure that you use the correct flow id. I have missed changing this when I copy my code to other lists with other flows.

    • Ah, yes, one more thing. Make sure that you have shared the flow with the user who click on the button.

  • Hi Laura,

    now it´s 2020 and this is still the best resource for a button. Great post!

    I am looking into a little more customization and I failed… Could you give me a hint for the JSON to achieve the following:

    I would like to have the text on the button change with the status column, that is referenced. And of course, I have more than 2 status options. So basically I would need a nested IF or whatever kind of Switch and then have the “txtContent” as part of that. The flow will stay the same.

    Could you give some guidance here? Thanks!

    • Ugh, logic in JSON is super painful. I wish I could help you, but every time I try to do something like this, it takes me hours and hours to figure out.

    • If I understand you correctly I don’t think this would be very difficult. This code works fine for me. Adjust it to your needs and add more code for more status options.
      {
      “elmType”: “div”,
      “txtContent”: “=if([$StatusColumn]==’A’, ‘Text is A’, if([$StatusColumn]==’B’, ‘Text is B’, ‘Neither A nor B is selected’))”
      }

  • Help please – I dont know Json and I’ve tried to put together some formatting but although the hiding works I just have a small purple vertcal rectangle rather than a button with text. Any help appreciated

    {
    “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
    “elmType”: “button”,
    “customRowAction”: {
    “action”: “executeFlow”,
    “actionParams”: “{\”id\”: \”1234567made up GUID\”, \”headerText\”:\”Confirm you want to request this software\”,\”runFlowButtonText\”:\”Confirm Request\”}”
    },
    “style”: {
    “background-color”: “purple”,
    “color”: “white”,
    “visibility”: {
    “operator”: “?”,
    “operands”: [
    {
    “operator”: “==”,
    “operands”: [
    “[$Status]”,
    “Rejected”
    ]
    },
    “hidden”,
    “visible”,
    “children”,
    [
    {
    “elmType”: “span”,
    “txtContent”: “Request this software”
    }
    ]
    ]
    }
    }
    }

    • I would do it like this:

      {
      “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
      “elmType”: “button”,
      “customRowAction”: {
      “action”: “executeFlow”,
      “actionParams”: “{\”id\”: \”1234567made up GUID\”, \”headerText\”:\”Confirm you want to request this software\”,\”runFlowButtonText\”:\”Confirm Request\”}”
      },
      “style”: {
      “background-color”: “purple”,
      “color”: “white”,
      “visibility”: “=if([$Status]==’Rejected’,’hidden’,’visible’)”
      },
      “txtContent”: “Request this software”
      }

  • Hi Laura,
    great job! Using this for all the lists with flow!

    1 thing I’m still trying to solve, maybe you may have a hint.

    On our tenant, when user clicks the button, the time between the button is clicked and the Flow Panel appears is something like 5+ seconds…
    Do you think there’s any way to have spinner on the list during this action via JSON? So then, user clicks the button, sees the spinner on the list until the Flow panel appears?
    Maybe it’s view formatting and not column formatting, i don’t know, my SP JSON capabilities are limited

    thanks and have a great day
    Karol

  • Hi Laura,

    Thanks a lot for this post. Its very helpful.
    It worked me perfectly.

    I’ve a question? can we add same idea “A button to run a flow” in the display form for the selected item?

    thanks

  • Invalid JSON?
    Why do i copy your JSON into a validator and it fails? Same thing in the JSON schema from the list formatting…..

  • Mr Akbar Mahfuz Alam

    Hi Laura,

    Is there any way out where I can change the button shape size and color on the Mobile app when I am using it on widgets.
    Because I have a couple of similar flow and similar buttons.

    Help or Video is highly appreciated.

    Thanks in advance

    • I’m not sure about the size and shape, but in the post I showed how to change it to purple. You can see the word “purple” in my code. Maybe for people who know CSS/styling, there’s a way, but I don’t really know code.

  • Hi Laura,

    Learned a lot from your post. I actually started learning SharePoint only after reading this post, before that SharePoint was boring for me.

    Thanks for making it interesting. 🙂

    • Also have a question:

      What is the use of “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”

      i have used few codes without it, which also works, is there any special output this link gives or it is just there as any reference?

      not sure about it, can you please help?

      Shubh.

    • I have no idea, it’s just in all of Microsoft’s documentation. Cool if you figured out that it’s not needed, but I’m not sure what it’s for.

  • Hello Laura,

    This is helpful information.

    I would like to add the hidden and visible hyperlink feature to my code when the Status is “In Progress” and “Under Review”. How would I go about doing so?

    {
    “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
    “elmType”: “button”,
    “customRowAction”: {
    “action”: “executeFlow”,
    “actionParams”: “{\”id\”: \”72cf3e93-2e04-441a-a155-d0684e21f945\”}”
    },
    “attributes”: {
    “class”: “ms-fontColor-themePrimary ms-fontColor-themeDarker–hover”
    },
    “style”: {
    “border”: “none”,
    “background-color”: “transparent”,
    “cursor”: “pointer”
    },
    “children”: [
    {
    “elmType”: “span”,
    “attributes”: {
    “iconName”: “Flow”
    },
    “style”: {
    “padding-right”: “6px”
    }
    },
    {
    “elmType”: “span”,
    “txtContent”: “Send for Review”
    }
    ]
    }

  • Hi Laura,

    I have a question

    i have read your article about implementing a button to run the flow in share-point list and its working fine. However, when you search for an item in share point list and click on the button to run the flow, it does not do anything. Can you please help me with this

    • Multiple people have mentioned that here in the comments. Sorry, it’s a bug. Maybe Microsoft will fix it?

    • I’m also experiencing the issue that the button is no longer working when your perform a search. It’s no longer working due to the fact that the search result list doesn’t contain a menu that holds the Flow action. Without selecting a doc, there’s no menu at all. But even after selecting a doc on the results page, the standard menu options (like Open, Delete, Rename, Download, Share, Copy, Move, ..) are all there, yet Power Automate/Automate are NOT showing up. As such the reference to the corresponding Flow is missing > hence no action

  • Hello Laura! Great work!
    Is there a way to make the button change color after it was clicked?

    • Hi Ron, I covered how to do something like that during Power Hour last week, towards the end. https://youtu.be/0ZfOy0Jemd4?t=3544
      You’d have to make your flow set some field value in the list item, so then the condition for the button to be different would be based on that field value, like a status or something. But it wouldn’t be instantaneous, it would happen a few seconds later when the flow runs.

  • Hi Laura,

    One question:
    Every time we click button and run the flow, the input box pops up.

    Is it possible to skip pressing the “Run flow” if we run a flow in SharePoint where there is no input to give?

    Eliminating the step would make process faster.

    Waiting for your ideas.

  • Hi Laura,

    Is it possible to change value of status column using this button without running flow?

    Like, when i click the button the value of status column automatically change to submitted from requested. but there should not be any flow to do it. just using JSON.

    Hope you understand my question.

    Thanks

  • Hi Laura,
    This article is great – pointed me in the correct direction.

    I have my flow running from a button if I am the owner.
    If the account I am running is not allowed to run the flow nothing happens – I was hoping for a “you do not have permission” type message. Because at the moment the user will click it – and if they have no experience of running flows – will have thought that it has run.

    Should I get that “you do not have permission ” type message ? – Is there any way of achieving it ?

    Also can you use SharePoint groups to give permissions – not just AD security groups ?

    • Mattias Sandberg

      Hi Cathrine!
      You can chose to hide the button if the logged in user is not permitted. just add this if-formula.
      “style”: {
      “display”: “=if(@me == ‘myemail@mydomain.com’, ‘none’, ‘block’)”
      }

      They can still run the flow from the Automation menu though. If they do you can then build in a test in the flow to check if the user is valid and then e-mail them an error message.

      I hope this will help. Have a nice day!

  • Hi, Laura. Thanks for maintaining this wonderful site! It’s really helping me get up to speed with Power stuff.

    I was able to implement your link-and-icon solution on my own list. Even customized it a little. I have two issues with it, though – and it’s not because of your code. First, users have to click a Run App button every time. Second, the changes cannot be seen without manually refreshing the screen.

    Is there any way around these inconveniences?

    Thanks again for you help!

  • Hi Laura,

    I was wondering if there is a way to make a clickable button to go to a folder in a documents library? The problem i have is each list item has its own folder i need to direct it to in the document library.

  • Hi Laura,

    If we use this on a document library which is used in MS Teams, you can see the button in Teams, but if you click on it, nothing happens. Do you have a solution for this?

    Regards,
    Raphael

  • Really well explained, thanks to this solution, I am able to put buttons to my sharepoint list, that too with conditions. Thanks for sharing

  • Hi! I really like this solution but I was wondering if there was a way to get the button to submit the actual “approve” response once clicked.

    I have a list that I use as a check list. Every time a new item populates, I want to have the button there so that I can “one click” and it sends the “approved” or “reviewed” response to the flow. No page changes, no comment box, just a button that sends the response.

    • If you were using a Power App and not going to the list, you could easily do that with a gallery and a Patch function. But no, not in the list in the browser.

  • Thank you laura for your post. That helped me a lot in implementing a requirement. Now Microsoft has published the gallery view in lists on SharePoint. Is it possible to include a button with “flow action” there too?

  • Hi Laura,
    Nice to read this all.
    Can you tell if (and how) it is possible to create a button on a modern SharePoint site to start a Flow (that has been defined as a button flow with manual input)?

    • Yes, but it just wouldn’t be on each item in a list or library. When you share a flow with someone as a run-only user, the email it sends has the link to directly trigger the flow, and then you can use that link on a button on your site or anywhere.

    • Maarten de Keijzer

      Thank you Laura! That did the trick, and we gonna use it.

  • Hi Laura, i have this deployed in a few places and its very helpful. The one thing that has come up a few times in policies is that it would be nice to either disable or change the colour of the button for that specific user only once they’ve excuted the flow once. Is that possible ?

    • Sure, you could use logic in the flow to set some field value in SharePoint, like call it status or something. Then, you’d have to figure out the JSON logic to show a different color per value of that status field.

  • Hi Laura, there is something frustrating invoking a flow; it is the fact you have to confirm the action even you do not have parameters to send to the flow. If you have to press on several buttons in the list then you have also to click on “run flow” several times as well.
    Is there a way so skip this stupid step?

  • Hi

    Thanks for your post, your code.
    I would like to adapt your code.
    Every line/buttom will launch its own flow .
    So I have your code and a column called IdFlow who contains the ID of the flow.
    But it doesn’t work, I tried with calculated column too and it’s the same :” Sorry, something went wrong”
    Any idea?

    Magali

    ={
    “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
    “elmType”: “button”,
    “customRowAction”: {
    “action”: “executeFlow”,
    “actionParams”: “{\”id\”: \”[IdFlow]\”}”
    },
    “attributes”: {
    “class”: “ms-fontColor-themePrimary ms-fontColor-themeDarker–hover”
    },
    “style”: {
    “border”: “none”,
    “background-color”: “transparent”,
    “cursor”: “pointer”
    },
    “children”: [
    {
    “elmType”: “span”,
    “attributes”: {
    “iconName”: “Flow”
    },
    “style”: {
    “padding-right”: “6px”
    }
    },
    {
    “elmType”: “span”,
    “txtContent”: “Start the Automate”
    }
    ]
    }

  • Thank you so much Laura. This has really blown the lid off my List/Flow ceiling. I’m very grateful.

    What do you think about adding a condition so the column shows different buttons (either just text running the same Flow or actually different Flows) depending on the status of another column?

  • Pingback: How to show the folder path of a file in library views – SharePoint Stuff

  • Greetings Laura!

    First thank You for great post!
    Also thank You for post about tabbed forms, really really helped.

    What do You think about button in Search Results? I created a bug about it:
    https://github.com/pnp/sp-dev-list-formatting/issues/302

    Strange that these executeFlow buttons do not fire for items returned from Search Results..

    Best regards,
    Gennady

  • How to add input parameters to your Flow’s trigger.(send logged in user name as input parameter to flow)

  • Fantastic post, thank you. Does this approach only apply to Flows saved in the ‘default’ environment? My company has forced us to create Flows in a different (non-default) environment. Consequently, I can’t use a “for selected item” sharepoint trigger. I imagine that simply copying the GUID as you describe above would not work correctly?

  • Hi Lisa,
    Really love this. With the visibility statement is there a way to have 2 values? Like IF Moderation status = “S” or “E”?

    Thanks

    • Hi Robin, “IF” conditions are…. interesting in JSON. I’m sure there’s a way to do it, but I just don’t know the syntax.

    • Jeremiah Benjamin

      Robin, I think I know what you’re asking. I did something similar a couple years ago for a project planning “board” using a List and some Flows.

      My apologies for the older JSON formatting syntax (the new Excel style is much more condensed and easier to read), but this one still works so I haven’t touched it. You can probably pick out the 4 possible status conditions (Planned, Eliminated, Approval Requested, and Approved). Either of those first 2 resulted in showing a button to Submit or Re-Submit the project for approval which fired off a Flow (the same flow for our process, but could be different flows). Just swap out your field name, conditions and flow IDs, and remove the sections you don’t need.

      {
      “$schema”: “https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json”,
      “elmType”: “span”,
      “style”: {
      “color”: “#009ada”
      },
      “children”: [
      {
      “elmType”: “button”,
      “style”: {
      “border”: “none”,
      “background-color”: “transparent”,
      “color”: “#009ada”,
      “cursor”: “pointer”,
      “display”: {
      “operator”: “?”,
      “operands”: [
      {
      “operator”: “==”,
      “operands”: [
      “Planned”,
      “[$Status]”
      ]
      },
      “”,
      “none”
      ]
      }
      },
      “txtContent”: “Submit for Approval”,
      “customRowAction”: {
      “action”: “executeFlow”,
      “actionParams”: “{\”id\”: \”f22dd696-5da9-4ccf-b0dd-6871da1e177a\”}”
      }
      },
      {
      “elmType”: “button”,
      “style”: {
      “border”: “none”,
      “background-color”: “transparent”,
      “color”: “#009ada”,
      “cursor”: “pointer”,
      “display”: {
      “operator”: “?”,
      “operands”: [
      {
      “operator”: “==”,
      “operands”: [
      “Eliminated”,
      “[$Status]”
      ]
      },
      “”,
      “none”
      ]
      }
      },
      “txtContent”: “Re-Submit for Approval”,
      “customRowAction”: {
      “action”: “executeFlow”,
      “actionParams”: “{\”id\”: \”f22dd696-5da9-4ccf-b0dd-6871da1e177a\”}”
      }
      },
      {
      “elmType”: “a”,
      “style”: {
      “font-weight”: “bold”,
      “display”: {
      “operator”: “?”,
      “operands”: [
      {
      “operator”: “==”,
      “operands”: [
      “Approval Requested”,
      “[$Status]”
      ]
      },
      “”,
      “none”
      ]
      }
      },
      “txtContent”: “@currentField”
      },
      {
      “elmType”: “a”,
      “style”: {
      “display”: {
      “operator”: “?”,
      “operands”: [
      {
      “operator”: “==”,
      “operands”: [
      “Approved”,
      “[$Status]”
      ]
      },
      “”,
      “none”
      ]
      }
      },
      “txtContent”: “”
      }
      ]
      }

  • Pingback: SharePoint: How To Build Buttons – Real Men Wear Spandex

  • Hi Laura,
    a giant thank you for these explanation that helped me to improve my Sharepoint List.
    Unfortunately, if it is working perfectly for me, my colleagues that should have authorization to run the flow do not see the flow on the right pan. When they click on the button, nothing appears on the right, it is like the flow does not exist for them but with my user no problem !
    I have given to my users E3 licence and I have added them to Run-Only Users in my flow. I don’t know what to do more !

    • Try different browsers and see if that’s the issue? Also, have them try clicking the Power Automate button in the list and triggering it that way, to see if they’re able to do that. That way, you’ll know if the problem is with the button or with the flow itself.

  • Finally, I have found the problem. There are a lot to know about Sharepoint List and Power Automate authorizations !
    Here are what I have must done to let my users access a poor manual flow on the list:
    1) give them an E3 O365 licence
    2) give them “Execute only” authorization on my flow using sharepoint members list
    3) give them back the autorization to Manage the sharepoint list and to Add new item !

    The last point seems to be very important, it is a bit pity that we must do that. Consequently, my users can add new columns or do what they want on the list ! Crazy !

    • I only ever use E1, so they don’t need E3 to be able to do this. Also, I’ve never had to do what you’re referring to in step 2.

  • {
    “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
    “elmType”: “div”,
    “customRowAction”: {
    “action”: “executeFlow”,
    “actionParams”: “{\”id\”: \”811ca48a-d1b9-4eec-a47e-f31fcc86a0d3\”}”
    },
    “attributes”: {
    “class”: “ms-fontColor-themePrimary ms-fontColor-themeDarker–hover”
    },
    “style”: {
    “border”: “none”,
    “background-color”: “transparent”,
    “cursor”: “pointer”
    },
    “children”: [
    {
    “elmType”: “span”,
    “attributes”: {
    “iconName”: “car”
    },
    “style”: {
    “padding-right”: “6px”
    }
    },
    {
    “elmType”: “button”,
    “txtContent”: “Send Pick Up Request”
    }
    ]
    }

  • Hi – Thanks for this really helpful tutorial.

    Is it possible to trigger a flow via a button from a custom SP List Edit from? I would like to create a button inside of my custom edit form that when pressed, kicks off the flow, much like you have demonstrated here, except it’s in the custom form. I tried creating this field in the list, then creating a button in the Edit form to essentially press the button in the list, but have had no luck. Any help would be greatly appreciated!

    • Disregard this – I’ve been struggling with this for a week straight and finally managed to figure it out 10 minutes after submitting this comment.

  • Laura,
    Is there a way for the buttons to be hidden unless someone selects the item. I have some people who think it would be more pleasing to the eye if the buttons were not visible all the time. I do have a visible check for if the Workflow has already been triggered already and they want that still as well.

    • I don’t know, maybe something could be done in the JSON code regarding the onhover? I’m not a dev, so I don’t know what the code would be.

  • AnnieyChris Cayrus

    Hi Laura! I used this great feature you shared in this post, but I’m struggling with the Column ID. The button remains “hidden” beacause of that. My column is called “¿Es alerta médica?”… Any thoughts?

  • Hi Laura, is there a way to get the button to execute from a gallery view. I have tried so many different custom formatting and searched high and low for videos or blogs about this but can’t seem to find anything. I can get the button on the gallery view but when you click it, nothing happens. It works fine from the list view.

  • Hi, Laura; Awesome tip! I use this a lot.
    One thing: the quotation marks in your code snips are using a non-standard font and need to be replaced when I copy and paste the code. So I have to manually replace all the quotes with standard quotation marks.

  • 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