Jan 20 2021 07:45 AM
Hello,
As in the subject- I would like to create hyperlinks to different sites under one column depending on the text value for the item on the list/library under that column. So for example item 1 is having value "X" under column "Y" and I want "X" to be hyperlinked to site "A", if the value of the item is "Z" I want hyperlink to site "Z" etc. Would someone be so nice and give an example?
Jan 20 2021 08:16 AM
SolutionBased on what I understood from your question, you need to use JSON in below format:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "@currentField",
"attributes": {
"href": "=if(@currentField == 'X', 'https://tenant.sharepoint.com/sites/A', if(@currentField == 'Z', 'https://tenant.sharepoint.com/sites/Z', 'https://tenant.sharepoint.com/sites/default'))",
"target": "_blank"
}
}
Add this code to column "Y" by selecting "Format this column" settings.
Documentation: Use column formatting to customize SharePoint
Please click Mark as Best Response 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.
Feb 28 2022 10:45 AM
Jan 20 2021 08:16 AM
SolutionBased on what I understood from your question, you need to use JSON in below format:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "@currentField",
"attributes": {
"href": "=if(@currentField == 'X', 'https://tenant.sharepoint.com/sites/A', if(@currentField == 'Z', 'https://tenant.sharepoint.com/sites/Z', 'https://tenant.sharepoint.com/sites/default'))",
"target": "_blank"
}
}
Add this code to column "Y" by selecting "Format this column" settings.
Documentation: Use column formatting to customize SharePoint
Please click Mark as Best Response 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.