SP Column Formatting - can you send data into a powerautomate flow?

John Adams 1 Reputation point
2020-12-05T11:12:36.803+00:00

I have created json column formatting based on a pnp sample, which shows an icon in a column, when pressed it kicks off a flow.
My question is, is there anyway to send data into that flow as well as kick it off? I need it to send the item ID, Library name and site URL.

the code i have so far is:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "='{\"id\": \"' + if(@me == @currentField.email,'b60a26d3-fd87-4947-9d1d-344cb31d953a',null) + '\"}'"
  },
  "attributes": {
    "class": "=if(@me == @currentField.email, 'ms-fontColor-themePrimary ms-fontWeight-semibold', '')"
  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "=if(@me == @currentField.email,'Pin','Checkbox')"
      },
      "style": {
        "padding-right": "6px"
      }
    }
  ]
}

as you can see the line:

"actionParams": "='{\"id\": \"' + if(@me == @currentField.email,'b60a26d3-fd87-4947-9d1d-344cb31d953a',null) + '\"}'"

kicks off a flow if the value is the same as the user logged in. I want to to not only kick off the flow but to also pass information into the flow , for the flow to act on.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,301 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Jerry Xu-MSFT 7,946 Reputation points
    2020-12-07T06:23:26.313+00:00

    Hi, @John Adams ,

    For using JSON formatting to trigger flow, we in fact have no need to pass the parameters like item id and folder path. And actually we are not able to do so. We only have the following parameters available in this custom action.

    The actionParams attribute can have the following options when using the executeFlow action:

    id: ID of the Flow to launch (required)
    headerText: Sets the text at the top of the flow panel (optional)
    runFlowButtonText: Sets the text of the primary button in the flow panel (optional)

    Reference: https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting#button-elements

    And we can set the flow trigger to be things like For the selected item/file. Then adding a Get file properties or Get item action will provide most of the information we need. Here is a demo I made in my end, the action provides most of the properties.

    45643-image.png
    45467-image.png

    Plus, for the conditional part, here is one thing you need pay attention to. For the "actionParams" , the id of the Flow is a required parameter. Thus it is not supported to provide a null value attempting to disable this button.

    One workaround works in my end is using the visibility property. By setting the button to be hidden, we can disable it based on your required conditional statements.

    I made a bit change on your original JSON, you can take it as a reference.

     {  
       "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",  
       "elmType": "button",  
    
       "customRowAction": {  
         "action": "executeFlow",  
         "actionParams": "{\"id\": \"f5b1cae3-1210-4026-bf7e-c6198b76a0b2\"}"  
       },  
       "attributes": {  
         "class": "=if(@me == @currentField.email, 'ms-fontColor-themePrimary ms-fontWeight-semibold', '')"  
       },  
       "style": {  
         "border": "none",  
         "background-color": "transparent",  
         "cursor": "pointer",  
         "visibility": "=if(@me == @currentField.email,'visible','hidden')"  
       },  
       "children": [  
         {  
           "elmType": "span",  
           "attributes": {  
             "iconName": "=if(@me == @currentField.email,'Pin','')"  
           },  
           "style": {  
             "padding-right": "6px"  
           }  
         }  
       ]  
     }  
    

    You can see only the last file has the pin button in the manager column which I set it as the current user I log in.

    45527-image.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. John Adams 1 Reputation point
    2020-12-09T11:02:16.007+00:00

    Thanks Jerry for your reply.

    How does one go about setting up the flow to accept this?
    It looks from your screen shots that i need to provide the site url and list for this to work? what if i want to use this JSON across multiple site collections and lists against the same flow?