Add a button in to a SharePoint List/Library to trigger a Flow (part 01)

Part 01 (This article)

Microsoft Flow together with PowerApps undoubtedly revolutionizing the process automation in modern work places. You may have a Flow attached to a document library or list but there is no easy access to initiate that flow from the list/library itself. People have to dig in a little bit to initiate it and that’s a little bit of time consuming for constant usage.

clip_image001

With this article, we will find out how we can overcome this struggle using a little bit of JSON stuff (Don’t worry about that word, you don’t need to be a developer here). Using the Modern SharePoint capabilities, we can embed a button right in front of every item in a list or library so that people can trigger a Flow right there. New column formatting is a cool out of the box capability to get this done.

Now let’s get this started. First and foremost, you need to have a Flow created in place and have the GUID of it.

We’ll get a Flow created really quick in case if you don’t have one. If you have a Flow already in place, you can skip these basic steps

Open up your SharePoint Library and click on the “Flow” drop down on the ribbon as below. Then go to “Create a Flow

1

You’ll see a list of available templates. You can utilize these templates if your requirement matches with them. Or simply feel free to create your own. Thankfully, there are a lot of templates published by Microsoft and the community which you can re-use on various scenarios. Unless the requirement is very specific or you are really keen on creating one your own, there is no point of designing a Flow from the scratch.

2

I am adding a simple “Request Manager Approval” flow here. Pretty straight forward.

4

Next, go ahead and check if the flow is added to “My Flows” section. If so, you are good to go.

5

Now go inside the created Flow by clicking on it and copy the highlighted GUID form the address bar of your browser. We need this for our new Button.

6

https://asia.flow.microsoft.com/manage/environments/Default-f50d518a-e13c-4359-85f6-ef76484f4c32/flows/e290feff-0013-41f2-97dd-91a37fb84ea0/details

Now to add the button but before that we need a new column for this button. From the list or library, go to the very end horizontally and add a new text column to this list/library.

10

11

It should be like below after adding. You can edit this view by dragging and dropping the desired column across the library if you wish to. I’m calling mine “Approval” so it makes scenes for a column contains buttons.

a

Now, go ahead and format this column. Click on the little arrow on the newly created column and go to format mode.

b

And paste the JSON code below. replace the GUID using the target flow which you have copied to the clip board.

c

Here’s the code (you will have it provisioned as you go to format mode itself).

{
  "$schema": "https://developer.microsoft.com/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": "Send to Approval",
      "customRowAction": {
        "action": "executeFlow",
        "actionParams": "{\"id\": \"e290feff-0013-41f2-97dd-91a37fb84ea0\"}"
      }
    }
  ]
}

That’s it and you will immediately notice the button applied to your column. This is how my library looks like after adding the button. It still doesn’t look like a button because of the border, background and colors of it.

14

Cool thing is ! you can customize the button to look like as you want it to be. Further more, you can also make it a logical button which has a condition behind it. (e.g. – show a button only when an item pending for approval).

Read the part 02 of this article series to further customize the button and apply conditions.

Detailed Microsoft article for this is here

DISCLAIMER NOTE: This is an enthusiast post and is not sponsored by Microsoft or any other vendor.

5 thoughts on “Add a button in to a SharePoint List/Library to trigger a Flow (part 01)

  1. Pingback: Convert Office Files in to PDFs using Microsoft Flow – Microsoft Cloud Services & Technology Journal

  2. Pingback: Add a button in to a SharePoint List/Library to trigger a Flow (part 02-customization) – Microsoft Cloud Services & Technology Journal

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s