List Hyperlink active based on value
Hi All,
I have a hyperlink column which need to get active only when display text is “Yes”. The two other option “No” and “Not Required” when entered should not create a hyperlink. Below is the code which gives me result accurately with all formatting but don’t want hyperlink for “No” and “Not Required”. Any help appreciated.
{
“$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
“elmType”: “div”,
“children”: [
{
“elmType”: “a”,
“style”: {
“box-sizing”: “border-box”,
“padding”: “4px 8px 5px 8px”,
“overflow”: “hidden”,
“text-overflow”: “ellipsis”,
“display”: “flex”,
“border-radius”: “16px”,
“height”: “24px”,
“align-items”: “center”,
“white-space”: “nowrap”,
“margin”: “4px 4px 4px 4px”
},
“txtContent”: “@currentField.desc”,
“attributes”: {
“href”: “@currentField”,
“class”: {
“operator”: “:”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“@currentField.desc”,
“Yes”
]
},
“sp-css-backgroundColor-BgGreen sp-css-borderColor-WhiteFont sp-field-fontSizeSmall sp-css-color-WhiteFont”,
{
“operator”: “:”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“@currentField.desc”,
“No”
]
},
“sp-css-backgroundColor-BgRed sp-css-borderColor-WhiteFont sp-field-fontSizeSmall sp-css-color-WhiteFont”,
{
“operator”: “:”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“@currentField.desc”,
“Not Required”
]
},
“sp-css-backgroundColor-BgGold sp-field-fontSizeSmall sp-css-color-GoldFont”,
{
“operator”: “:”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“@currentField.desc”,
“”
]
},
“”,
“sp-field-borderAllRegular sp-field-borderAllSolid sp-css-borderColor-neutralSecondary”
]
}
]
}
]
}
]
}
}
}
]
}
Hi All, I have a hyperlink column which need to get active only when display text is “Yes”. The two other option “No” and “Not Required” when entered should not create a hyperlink. Below is the code which gives me result accurately with all formatting but don’t want hyperlink for “No” and “Not Required”. Any help appreciated. {
“$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
“elmType”: “div”,
“children”: [
{
“elmType”: “a”,
“style”: {
“box-sizing”: “border-box”,
“padding”: “4px 8px 5px 8px”,
“overflow”: “hidden”,
“text-overflow”: “ellipsis”,
“display”: “flex”,
“border-radius”: “16px”,
“height”: “24px”,
“align-items”: “center”,
“white-space”: “nowrap”,
“margin”: “4px 4px 4px 4px”
},
“txtContent”: “@currentField.desc”,
“attributes”: {
“href”: “@currentField”,
“class”: {
“operator”: “:”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“@currentField.desc”,
“Yes”
]
},
“sp-css-backgroundColor-BgGreen sp-css-borderColor-WhiteFont sp-field-fontSizeSmall sp-css-color-WhiteFont”,
{
“operator”: “:”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“@currentField.desc”,
“No”
]
},
“sp-css-backgroundColor-BgRed sp-css-borderColor-WhiteFont sp-field-fontSizeSmall sp-css-color-WhiteFont”,
{
“operator”: “:”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“@currentField.desc”,
“Not Required”
]
},
“sp-css-backgroundColor-BgGold sp-field-fontSizeSmall sp-css-color-GoldFont”,
{
“operator”: “:”,
“operands”: [
{
“operator”: “==”,
“operands”: [
“@currentField.desc”,
“”
]
},
“”,
“sp-field-borderAllRegular sp-field-borderAllSolid sp-css-borderColor-neutralSecondary”
]
}
]
}
]
}
]
}
}
}
]
} Read More