SOLVED

Hiding Icon in Hyperlink Column with No Link

New Contributor

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"
}
}
 
 
3 Replies
best response confirmed by mstevens22 (New Contributor)
Solution
Never mind I figured it out! I replaced the "iconName" with the following:
"iconName": "=if(@currentField =='','','Mail')",

@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.

@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.