Hide JSON built hyperlink in SharePoint list if there’s no underlying link

“Is there any way to modify the JSON on SharePoint column to hide the “Open” link if there’s no underlying hyperlink?”

I have a list with links to documents, but there isn’t always a link because there isn’t always a document yet. I don’t want people getting frustrated with dead links.”


When using JSON to format a hyperlink, e.g. to replace Calculated column with hyperlink, you might have some items where the link is empty. In that case you’ll end up with the description text, but no link on the background. Text that look like a link, but leads nowhere. How can you hide this fields and keep only the exiting ones?

Add “style” to the JSON

You can extend the JSON column formatting by adding “style” attribute with an ‘if condition’. If the column with link is empty, apply style “display: none” to hide the column. Otherwise use “display: inherit” to show the link.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "Open",
  "attributes": {
    "target": "_blank",
    "href": "@currentField"
  },
  "style": {
    "display": "=if(@currentField == '', 'none', 'inherit')"
  }
}

The piece of code above will display text “Open” only if the current field is not empty. And you can use not only the current field, but also any other column referenced by [$columName] in the condition.

sharepoint hide json hyperlink column with no hyperlink

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to a special content like a SharePoint Filter Query cheat sheet.

Zero spam, unsubscribe anytime.

Add a Comment

Your email address will not be published. Required fields are marked *