SOLVED

List Formatting - Conditional Button to start Flows

Contributor

Hi,

 

I got this button to start a Flow out of a list right now. This works fine:

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"aace4a99-3b30-xxxx-bbf6-c8c9dc134fda\"}"
  },
  "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": "Step 3"
    }
  ]
}

 

My goal is to have a button that switches the Flow ID and its Text depending on a boolean column called Finished in the list.

 

If Finished is false then the button text and Flow ID should be like above. If Finished is true then the button text and Flow ID should be changed to other values. 

 

Tried lots of things like this, but it always just showed the formula on the button:

    {
      "elmType": "span",
      "txtContent": "=if($Finished == true),'FinishedTrue','FinishedFalse'"
    }

 

Hope there is someone out there giving me an hint how to accomplish this. 

 

Thank you! 

1 Reply
best response confirmed by Philipp Hammer (Contributor)
Solution

After further digging on Microsoft Docs I got a solution for this. *facepalm*

Hope this helps someone else as well. 

If boolean column "Finished" is false:
-> starts Power Automate Flow A and shows button text "Step 3"
If boolean column "Finished" is true:
-> starts Power Automate Flow B and shows button text "Step 4"

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": 
		   {
          "operator": ":",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "[$Finished]",
                true
              ]
            },
            "{\"id\": \"e574c8fb-231b-bbbb-b96a-b8e5025b0410\"}",
            "{\"id\": \"aace4a99-3b30-aaaa-bbf6-c8c9dc134fda\"}"
          ]
      }
	
  },
  "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": 
	   {
          "operator": ":",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "[$Finished]",
                true
              ]
            },
            "Step 4",
            "Step 3"
          ]
      }
    }
  ]
}