Skip to content

Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Problems
  • Triggers
  • Application specific solutions
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
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

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 resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Leave a Reply Cancel reply

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

Now available:

The Ultimate Power Automate expressions cheat sheet
Equip yourself with the tool to translate your thoughts into Power Automate expressions!

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 resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Check if email already exists in Outlook contacts (Power Automate)August 7, 2022
  • Set permissions for a SharePoint list or library with Power AutomateAugust 3, 2022
  • Handle deleted files in synchronised SP library in Power AutomateJuly 31, 2022
  • Create item with lookup column in a dynamic list (Power Automate)July 27, 2022
  • How to move list between SharePoint tenants with Power AutomateJuly 24, 2022

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

© 2022 Let's POWER Automate | Powered by Superbs Personal Blog theme