Forum Discussion
JSON Column Formatting help with Condition statement for displaying Hyperlink alternate txt
- Jul 15, 2022
Oberke2380 Use this JSON:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "children": [ { "elmType": "a", "style": { "display": "=if(@currentField == '', 'none', 'block')" }, "attributes": { "href": "@currentField", "target": "_blank" }, "txtContent": "Whiteboard" }, { "elmType": "span", "style": { "display": "=if(@currentField == '', 'block', 'none')" }, "txtContent": "Creating Whiteboard" } ] }
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.
Oberke2380 Use below JSON code:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"style": {
"display": "=if(@currentField == '', 'none', 'block')"
},
"attributes": {
"href": "@currentField",
"target": "_blank"
},
"txtContent": "Whiteboard"
}
Output:
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.
Thanks, This works!
Is there way to modify it where instead of being blank when Column is empty, it says "Creating Whiteboard" ? (Since its only a short amount of time until the flow triggers and creates the whiteboard and populates this field with a link.
- ganeshsanapJul 15, 2022MVP
Oberke2380 Use this JSON:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "children": [ { "elmType": "a", "style": { "display": "=if(@currentField == '', 'none', 'block')" }, "attributes": { "href": "@currentField", "target": "_blank" }, "txtContent": "Whiteboard" }, { "elmType": "span", "style": { "display": "=if(@currentField == '', 'block', 'none')" }, "txtContent": "Creating Whiteboard" } ] }
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.