SharePoint Online JSON Hyperlink Column Formatting - If empty

Viewed 34

I am trying to make a hyperlink column to appear "NA" if empty but if a hyperlink is inputted to show as a clickable "View MSA".

I am able to achieve the latter as a clickable link but can't seem to get the if empty/blank working using IF statement.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "attributes": {
    "href": "@currentField",
    "target": "_blank"
  },
  "txtContent": "View MSA"
}

Outcome

1 Answers

Someone provided me with a solution;

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "attributes": {
    "href": "@currentField",
    "target": "_blank"
  },
  "txtContent": "=if(@currentField == '', 'NA','View MSA')"
}
Related