Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Outlook
    • Planner
    • Power Apps
    • SharePoint
    • Teams
  • Triggers
  • Ready to use solutions
    • Approval Process Template
    • Task Delegation App
    • The Ultimate Power Automate expressions cheat sheet
    • Power Automate HTTP requests to SharePoint cheat sheet
    • Power Automate HTTP requests to Graph API cheat sheet
  • ABOUT ME
  • Get help with your flow
  • POWER PLATFORM SERVICES
Menu

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

Posted on December 9, 2020April 14, 2021 by Tom

“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

🚀 Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

4 thoughts on “Hide JSON built hyperlink in SharePoint list if there’s no underlying link”

  1. Richard Nordvik Vetås says:
    November 23, 2022 at 12:15 pm

    Is there a way to change the color of the link using JSON?

    Reply
    1. Tom says:
      December 5, 2022 at 7:55 pm

      Hello Richard,
      yes, you can add “style” property in the JSON as shown in this article (in a more complicated way): https://tomriha.com/format-results-of-date-calculation-in-sharepoint-column/.
      “style”: {
      “color”: “”
      }

      Reply
  2. Kundani says:
    May 3, 2023 at 10:27 am

    I tried this Json script below to try to make show the link as an SDS on a column but is still showing the entire link
    what could be the problem
    {
    “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
    “elmType”: “a”,
    “txtContent”: “SDS”,
    “attributes”: {
    “target”: “_blank”,
    “href”: “@currentField” }
    }

    Reply
    1. Tom says:
      May 28, 2023 at 2:51 pm

      Hello Kundani,
      the JSON looks fine, is it applied on the column? Didn’t you maybe switch a view?

      Reply

Leave a Reply Cancel reply

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

🚀 Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

Working on an Approval process?

Use the Approval Process Template and the Task Delegation App to skip the hard part and deploy a fully functional approval solution on a SharePoint list in minutes! And then the next one, and the next one...

Approval Template Preview ✨ Learn more ✨

Turn ideas into flows with ease!

Grab the complete Power Automate Cheat Sheet Bundle—everything you need to master expressions, SharePoint HTTP calls, and Graph API in Power Automate.

Cheat Sheet Bundle Preview ✨ Get the Cheat Sheets

Didn't find what you were looking for?
Need to adjust a solution to fit your needs?
Or would you just like to get an assistance from somebody with thousands of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2025 Let's POWER Automate | Theme by SuperbThemes