Forum Discussion
Conditional column formatting to create hyperlink to different sites based on item value
- Jan 20, 2021
Based 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.
Based 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.
- DeclanHalpinFeb 28, 2022Copper ContributorI am trying to do something similar, but with one additional twist:
I have two Sharepoint lists: "Projects" and "Items". Each project will have multiple items associated to it. So, imagine project "Ice Cream" has items ["Buy Ice Cream", "Eat Ice Cream", "Take Nap"]. All three of the items have a column called Master_ID which is populated with the Sharepoint ID of the parent project.
I would like to be able to click on the Project ID# and have it link to the Item list, but with the view filtered to show only the corresponding Items (Filter Master_ID).
I'm not a programmer, so I'm hoping someone can help me get my brain around it.
Thanks in advance!