Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
2.4k views
in SharePoint Online by 1 1 1

I need help to achieve something that seems quite possible and easy but can't get that to work... I am not used to codes so please help. I want a field to be clickable to open a specific URL depending on the selection of another field. I am open to getting the field clickable but unable to add the dependence on the selection of the other field to work.

  1. I have a choice field with the different carriers (Purolator, Fedex, UPS etc....
  2. I have the field where the tracking number is being added.... clickable but can't get the check to my choice column working

Basically, the idea is

{

"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",

"elmType": "a",

"txtContent": "@currentField",

"attributes": {

"target": "_blank",

"href": "='https://www.purolator.com/en/shipping/tracker?pins=' + @currentField"

}

 


1 Answer

1 like 0 dislike
by 158 184 366

SharePoint Hyperlink Conditional Formatting based on another Field Value

In SharePoint Online, you can easily use JSON conditional formatting to show different links based on another field value selection by using Nested-IF as below

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "target": "_blank",
    "href": "=if([$Carrier]='Purolator','https://www.purolator.com/en/shipping/tracker?pins=' + @currentField, if([$Carrier]='Fedex','https://www.fedex.com/fedextrack/?trknbr=' + @currentField, 'https://debug.to'))"
  }
}

The above JSON formatting should be working fine for different hyperlinks based on another field value selection and you can add multiple IF conditions based on your requirements.

See also

If you don’t ask, the answer is always NO!
...