Forum Discussion
Oberke2380
Jul 14, 2022Copper Contributor
JSON Column Formatting help with Condition statement for displaying Hyperlink alternate txt
I have a SharePoint list, which I have a single line of text column that will contain an URL link. To start with this column is blank and does not show on the new for item form. It gets populated b...
- 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.
ganeshsanap
Jul 15, 2022MVP
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.
Oberke2380
Jul 15, 2022Copper Contributor
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.