0

Good Morning, I'm trying to customize a column in my SharePoint in order to:

  • send the user to a different action depending on the value of the column "status".

Ex1.: the customize column will show a button that will start a flow if the status is "in Progress".

Ex2.: the customized column will show a button that will send the user to the flow approval page if other status.

  • show a different text depending on the status.

So what I did is the following

`{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "=if([$Status] == 'In progress', 'button','a')",
    "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"aa12ed12-ea81-4128-bf1c-2112d0d126b1\"}"
  },
    "attributes": {
    "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover",
      "target": "_blank",
    "href": "http://finance.yahoo.com/quote/"
  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "=if([$Status] == 'In progress', 'Flow','RedEye')"
      },
      "style": {
        "padding-right": "6px"
      }
    },
    {
      "elmType": "span",
      "txtContent": "=if([$Status] == 'In progress', 'Start the Approval','See approval requests')"
    }
  ]
}`

As you can see the statement elmType wont work with an if statement. But it does what i need to do if i switch the elmType in "a" or "button". So how can I make it work? Thanks in advance. Have a nice day

1 Answer 1

0

Per my test, I get the same result as yours. I tried to refer other columns value in elmtype element but failed. Looks like we cannot do any operators in the elmtype.

The elmType must be one of div span a img svg button path.

Besides, you could use "debugMode": true to turn on debug mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.