SPO: Create Hyperlink from Calculated Column
Question
I know there are several questions/answers for this, but I still can't seem to get it to work.
Name - Text
URL - Text
Link - Calculated Column Number
Link column
=CONCATENATE("<a href='",URL,"' target='_blank'>",Name,"</a>")
If I add this into the Column Formatting for Link
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "[$Name]",
"attributes": {
"target": "_blank",
"href": "="[$URL]" + [$Name]"
}
}
When I go back to the list, Link is empty
I thought I had followed all the guides and what not, but... Any thoughts?
Solution
Try with this json:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "[$InternalNameOfYourNameColumn]",
"attributes": {
"target": "_blank",
"href": "[$URL]"
}
}
Btw, Name
should be reserved name, so the internal name of your Name
column is probably different than the display name and you should use that internal name in json formula (just replace InternalNameOfYourNameColumn
in my formula with the appropriate value).
OTHER TIPS
We can use the JSON formatting below to achieve it.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"style": {
"display": "table",
"width": "100%"
},
"children": [
{
"elmType": "a",
"txtContent": "[$Name]",
"attributes": {
"target": "_blank",
"href": "[$URL]"
},
"style": {
"display": "table-cell",
"text-align": "left",
"vertical-align": "middle"
}
}
]
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange