Mar 06 2023 11:15 PM
I'm attempting to change the hyperlink depending on a choice column "RequestType". Have been unable to set the url while also adding in a column data. Here is what I have tried.
First Test
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "Net Link",
"attributes": {
"href": "=if([$RequestType] = 'Create', 'https://removelink.=' + [$TicketNumber], if([$RequestType] = 'Move', 'https://link/ticketid=' + [$TicketNumber], '<Home Link>'))",
"target": "_blank"
}
}
Second Test:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "a",
"txtContent": "Link - build",
"attributes": {
"href": "=if([$RequestType] = 'Create', 'https://link/ticketid=' + [$TicketNumber]",
"Target": "_blank"
}
},
{
"elmType": "a",
"txtContent": "Link - Transfer",
"attributes": {
"href": "=if([$RequestType] = 'Move', 'https://link/ticketid=' + [$MACTicketNumber]",
"target": "_blank"
}
}
]
}
Mar 06 2023 11:36 PM
Hi @Ant__thony
you need to use "==" in a comparison (https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/formatting-syntax-referen...)
This code works for me
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "Net Link",
"attributes": {
"href": "=if([$RequestType] == 'Create', 'https://removelink.=' + [$TicketNumber], if([$RequestType] == 'Move', 'https://link/ticketid=' + [$TicketNumber], '<Home Link>'))",
"target": "_blank"
}
}
(Well... and RequestType and TicketNumber need to be in the view)
Best Regards,
Sven
Mar 06 2023 11:48 PM
Solution@Ant__thony Use JSON formatting in this format:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "Net Link",
"attributes": {
"href": "=if([$RequestType] == 'Create', 'https://removelink.=' + [$TicketNumber], if([$RequestType] == 'Move', 'https://link/ticketid=' + [$TicketNumber], 'https://www.google.com/'))",
"target": "_blank"
}
}
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.
For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs
Mar 07 2023 12:26 AM