Add a Button to SharePoint Online List

Introduction

Enhance your SharePoint Online experience with the power of Microsoft Lists and Power Automate. Discover how to elevate collaboration by integrating a custom Power Automate flow into SharePoint lists, and add a button to a SharePoint List for streamlined operations. This combination ignites a more efficient, interactive, and productive SharePoint environment.

Process

In this post I’ll go through the process of creating a power automate flow and then show you have to add the button to a Sharepoint.

To get started, all I did was add the Lists tab to my Demo Team in to Teams and used the travel requests template. Then I created a placeholder request.

Add Lists Tab
Travel Requests Template

The nice thing about this template is that it already has a built in approval column which we can use to update the list item in power automate.

Even though we’re in Teams, some of this underlying configuration is just easier/required to be done in a web browser.

Next, lets go to the approval area. You’ll use the default approval (Approvals) and an option for power automate. Let’s take a quick detour to discuss power automate so we’re on the same page.

Power Automate Detour

Microsoft originally released a product called flow as their automation platform. Similar to their marketing confusion with teams, you created flows with flow. Then Microsoft rebranded Flow to be Power Automate to lump it into their “Power Platform” of Power Bi, PowerApps, and PowerAutomate.

This is not an in-depth deep drive into all aspects of Power Automate, this is just a brief overview into the licensing required for this button flow to run.

License Options

  • PowerAutomate Plan 1/Free/included with all Office 365 subscriptions
  • PowerAutomate Plan 2
  • PowerAutomate Business Flows

Lets get the overkill one out of the way. Business Flows are licensed on a per flow and intended for main line of business processes. This is overkill for this solution. Plan 1 and Plan 2 are licensed on a per user basis. Plan 2 is required when you want to integrate with on-prem databases and/or 3rd party software.

For this flow all you need is Plan 1. Because of the Power Automate integration with SharePoint. You get most of the benefits of a business flow without having to pay for it.

Power Automate Plans

Power Automate Plan 1 is included with essentially all Office 365 subscriptions. I’m currently using Microsoft Business Essentials ($5) a month plan.

SharePoint List Configuration

To make this list a complete solution, we need to add 2 items for PowerAutomate to work, and I’d like to add a 3rd to make this list more useful, but it’s optional.

  • Add a column to hold the flow button
  • Add a column to hold the Approver for the request (Optional)
  • Add a PowerAutoMate Flow from SharePoint

Adding SharePoint Online List Columns

To add columns to the List, I find it easier to do this from the SharePoint Web Site rather then doing it through Teams.

Open in SharePoint

Click on the 3 dots and select Open in SharePoint to open the list in your web browser.

Default List in Web Browser

Moving right along, lets create the new columns.

Add Column

When you click on Add Column, you are presented the most popular options or the the option to select more types.

Column Options

For the Flow Button Create a Single Line of text column.

Submission Column

Give the Column a Name that make sense for your deployment and click Save.

We’ll circle back to the column to format it to show icons.

Next, Lets add that Approver Column for easy record keeping.

Click on the Add Column Button and Select a Person Column type.

Column Types

Similar to the first column, we have to give this column a Name, and tweak a couple optional settings.

Person Column

Give the column a name and a description if you’d like. Personally I like to enable the Show Profile Photos option, but this is totally up to you.

When you’re done click Save to create the column.

Power Automate Configuration

Now that SharePoint is ready, let’s configure a Power Automate Flow.

Configure Flows

Click on the Automate Button, select Power Automate and Configure flows.

You will be presented with the option for how you want Power Automate to operate on this list.

Leave the default of Request sign-off selected and click save.

Next, go to back to the Automate button, Select Power Automate, and then select Create a flow.

Create A flow

Select Request approval in Teams for a Selected item in SharePoint.

Currently this template is on the popular short list, as lists and Power Automate grows this may shift down under the show more section or you may need to search for it from the show more section.

You can build this template manually if you want to but, If Microsoft has done most of the work for you, why do it the hard way?

After you select the template from the list the browser will open a new tab in Power Automate.

Template Deployment

The template page shows a brief description, and the services required for the flow to work.

Click Continue to deploy the template.

Because we launched the new flow wizard from SharePoint, Power Automate brought in some of the SharePoint information by default.

Default Information

I’ll be starting at the top of the flow and working down. Starting at the Create Approval step.

Create an Approval

For the Create an approval (v2) here are my recommendations for the fields, The red * denotes which fields are required.

  • Title: Title section I’d recommend using a standard syntax mixed with the name of the list item.
  • Assigned To: Use the Approver Dynamic Content from the For A Selected Item. The Dynamic Content from Get item won’t work.
  • Item Link (Optional): use link to item to provide a link in the approval to the specific item you’re asking for approval for.

Going down the left side of the parallel track and scroll down to the Condition step.

Default Conditional Step Configuration

In the If Yes section, we’ll be adding a step under the Inform requestor of approval step.

Click on Add an action and select update item.

Update Item

After you select the Update Item, you will have to fill in the required and updated fields.

Update Item after approval
  • Site Address: Select the URL from the drop down menu
  • List Name: Select the list name from the drop down list
  • ID: Select the ID from the Dynamic Content option from For a Selected item.
  • Approved?: Change this to Yes
  • Approver Claims: Select Responses Approver email

Now that the flow is configured, click Save at the bottom of the flow.

After the save process is complete, click the Back arrow to go back to the properties of the flow.

Back button

Power Automate Permissions

On the properties page, we have to add/verify the SharePoint list is an owner of the flow.

Flow Properties

Click Edit on the owners section

Owners Properties

In the Owners Section select SharePoint.

Add SharePoint Owner

Select the SharePoint Site and List/Library and click Add.

Added Owner

Afterwards, the SharePoint List will be listed below the Add Section.

Before you switch back to SharePoint, Copy the URL for the flow to notepad. We’re going to need the GUID of the flow for the next step.

Flow GUID

Back to SharePoint

Go back to the SharePoint List, and click on the Submission Column Drop Down Menu.

Format Column

Go to Column settings, and then Format this column.

SharePoint will give you some options based on the column type, but in this case we need Advanced mode.

Advanced Mode

Click on Advanced Mode, and you’ll see that the window will change into a code editing style box. SharePoint has JSON formatting to standardize the customization model for SharePoint Online. Further more they put ALL of their icons into the Office UI framework which is based on React. Because of these 2 items it allows us to easily create these items in a standardized and supportable model.

blank Advanced mode

This in this step, we’re going to need that Flow GUID from the Power Automate step above.

JSON Code

In the code section below, you can copy and paste into notepad/notepad++ for editing. There is 1 line you have to edit and 2 other you can customized for your need.

  • Line 6: Update this section with the GUID from the Flow URL
  • Line 20: If you want to change icon in the button change the Office UI Fabric icon name here.
  • Line 28: If you want to change the text next to the icon, change the text between the quotes.

Full SharePoint JSON Reference from Microsoft.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"Flow GUID\"}"
  },
  "attributes": {
    "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "DocumentApproval"
      },
      "style": {
        "padding-right": "6px"
      }
    },
    {
      "elmType": "span",
      "txtContent": "Submit for Approval"
    }
  ]
}

After you’ve updated the JSON code, paste into the Advanced Mode box. Then use the Preview button it to make sure everything looks right.

Once everything checks out, Click Save and then the button will appear.

You can see the button in web browser or in teams.

Submit for Approval Button

Now that this automation flow have are created you’re good to go.

Final Thoughts

Now that the automation is in place, If you haven’t done so let you may want to create some new views in SharePoint and update some of the drop down values in the list itself.

Lastly, if you or your users click on the newly created button for the first time and it just spins. Have the user close the power automate pop up and open the request in the web browser to re run it. Some time the initial permissions request doesn’t prompt within Teams. This is a one time issue.