Forum Discussion

mstevens22's avatar
mstevens22
Copper Contributor
Nov 09, 2022

Hiding Icon in Hyperlink Column with No Link

I am using the following JSON to replace the Link in a Hyperlink Column with an Icon. However the icon shows even if there is no link entered in the column. How can I make it so the linkable Icon is only visible when there is actually a link?

 

{
"elmType": "a",
"attributes": {
"iconName": "Mail",
"class": "ms-fontColor-neutralDark",
"href": "=@currentField",
"target": "_blank"
},
"style": {
"font-size": "30px",
"text-decoration": "none",
"padding-left": "15px"
}
}
 
 
  • Never mind I figured it out! I replaced the "iconName" with the following:
    "iconName": "=if(@currentField =='','','Mail')",
  • mstevens22's avatar
    mstevens22
    Copper Contributor
    Never mind I figured it out! I replaced the "iconName" with the following:
    "iconName": "=if(@currentField =='','','Mail')",
    • ganeshsanap's avatar
      ganeshsanap
      MVP

      mstevens22 Or simply use like: 

       

      "iconName": "=if(@currentField,'Mail','')",

       


      Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

    • ganeshsanap's avatar
      ganeshsanap
      MVP

      mstevens22 Or you can use "display" property inside style to remove the complete anchor element: 

       

      "display": "=if(@currentField, 'block', 'none')"

      Or "visibility" property to hide complete anchor element from UI.

       


      Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources