2

I have configured button in my list, that triggers particular flow. However I would like the button to be visible only if there is value filled in particular column (e.g. column "Name").

Cannot make it work as whenever I'm filling ANY condition as "display" or "visibility", button just disappears:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "txtContent": "Trigger action",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \""}"
  },
  "style": {
    "background-color": "red",
    "color": "white",
    "font-weight": "bold",
    "display": "=if(([$Name] != ''),'visible')"
  }
}

Any suggestions?

0
2

If your "Name" column is of type "Single line of text", use below for display attribute:

"display": "=if([$Name] != '', 'block', 'none')"

If your "Name" column is of type "Person or Group", use below for display attribute:

"display": "=if([$Name.title] != '', 'block', 'none')"

Note: In JSON formatting, you have to use internal name of your column.


Update from comments:

In case of date column, use below:

"display": "=if(Number([$Name]) != 0, 'block', 'none')"

You can find other ways to check if date & time column is empty or not at: SharePoint JSON formatting: Check if date & time column is blank/empty

4
  • Hello Ganesh, thank you for answer. I confirm that this works in case of "Single line of text". However, in my case, the column is "Date & Time" type. What is necessary to add then?
    – Vardenf
    May 8 at 23:52
  • Already tried (lets stay with "Name"): $Name.toLocaleString, $Name.toLocaleDateString, $Name.toLocaleTimeString, $Name.Date
    – Vardenf
    May 9 at 0:04
  • Check my updated answer for date columns. May 9 at 5:06
  • 1
    Works like a charm, thank you!
    – Vardenf
    May 9 at 10:14

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.