1

I got this problem:

I got a column named "TrackingNumber". In this column I want to be able to click on the displayed Number.

The extra feature is, that in another column, there is the shipping company.

Now I would like to ensure that if, for example, "DHL" is entered as the shipping company in the "shipping" field, the DHL tracking link is used.

However, if another company is against in the "shipping" field, the other link should be used.

Right now I have the following:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "href": "=if([$note.]=='1'),'https://mydhl.express.dhl/at/de/tracking.html#/results?id=6678310192', if([$note.title]=='2', 'https://www.post.at/en/sv/item-details?snr=1034598500013780802765'))",
    "target": "_blank"
  }
}

Unfortunately, the tracking number is no longer displayed for this version.

Could someone help me here, please?

1
  • Are you using SharePoint online or 2019? What is the internal name and data type of your other column? – Ganesh Sanap Nov 30 '20 at 9:19
0

I can see there are some syntax error in your JSON code.

Assuming you have column with internal name as "shipping" which holds company name and this is simple column like single line of text or choice. You can build your if condition like:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "a",
    "txtContent": "@currentField",
    "attributes": {
        "href": "=if([$shipping] == 'DHL', 'https://mydhl.express.dhl/at/de/tracking.html#/results?id=6678310192', if([$shipping] == 'Other Company', 'https://www.post.at/en/sv/item-details?snr=1034598500013780802765', '<default URL in case other conditions not met>'))",
        "target": "_blank"
    }
}

Make sure you use correct internal name of your field instead of shipping at [$shipping].

Also, you can provide any default URL in place of <default URL in case other conditions not met>.

Microsoft documentation: Use column formatting to customize SharePoint

8
  • Thanks for your fast answer. But it wont open if "DHL" is inserted in the shipping column. If nothing is inserted in the shipping column, it opens the "default url" U got a solution here as well? – Oliver Nov 30 '20 at 9:57
  • What is the internal name and data type of your other column which holds shipping company? – Ganesh Sanap Nov 30 '20 at 10:52
  • name: shipping Type: single line of text – Oliver Nov 30 '20 at 10:55
  • ok, I have updated JSON code in my answer. there was some mistake in position of ). Try using new code – Ganesh Sanap Nov 30 '20 at 11:00
  • It works Thank you very much! – Oliver Nov 30 '20 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.