Power Automate – Trigger Flow from SharePoint List column

Introduction

Hi Friends, let us see how we can trigger a flow from the SharePoint list column with no code option. To achieve, we will leverage the column formatting option, which is an impressive feature in the latest SharePoint versions, both on-premise and on SharePoint Online.

Buiness scenario

There are business case scenarios where the user’s input and actions are required to trigger a flow. Mostly on the approval process, users must provide their comments and other information before approving or rejecting the request. To do this, we don’t need to create a custom form using PowerApps or SPFx and then do all the validations to trigger to the flow. To keep things simple, we can do this using a column formatting option and the executeFlow action to trigger the flow.

Focus on the flow

I have seen in some of the forums where the users are experiencing issues when they are trying to trigger a flow from SharePoint List, which works great when they are testing in the flow site. Here I will walk through you to make the flow work with the action called ‘SharePoint – For a selected item.’ Let us see how we can use this action to trigger a flow from the SharePoint list and capture some information on the item that triggered the flow.

  1. Create an ‘Instant–from blank‘ flow and choose ‘SharePoint – For a selected item‘ trigger.

2. Select the site address, list and I have also added a text input to capture the comments. This will be captured when the user tries to trigger the flow from ShaerPoint List.

3. Save the flow. Capture the flow ID from the address bar that had to be used in the json code to trigger the flow.

Note: The flow created like this cannot be tested like the other flow because of the trigger that we had used. So better design the flow with the business case, test it and then create a new flow with the above mentioned trigger and copy-paste all the actions.

Focus on the SharePoint List

I hope many of them are aware of the column formatting option. The formatting allows us to customize the design of the field to change the rendering option. The same will enable us to create a link, button, and other controls from where the flow can be triggered. Let us see how we can format a column and trigger the flow.

  1. Create a custom list with any name and create a column of type ‘Single line of text’.
  2. Click on the newly created column and select ‘Column Settings‘ and choose ‘Format this column‘.

3. Paste the below mentioned json and click save.

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

4. Modify <Flow ID> param with the actual flow id and change the design as you wish. So all the work is done, isn’t so simple without writing bunch of lines of code?

5. When you click the button ‘Testing Flow“, a panel is opened to capture the “Comments” with some flow information and once the comments were entered, the flow is triggered successfully.

Useful references

Happy automating…

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