1

I'm wanting to create a clickable link using JSON column formatting, for a product code (like CRM 31/22) by referring to a hypertext link in another column called CRM_URL.

I am trying this:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "target": "_blank",
    "href":"=@$CRM_URL"
  }
}

But it doesn't parse the content of the field called CRM_URL, it simply generates a hyperlink comprising the list URL + "CRM_URL".

What I'm trying to do is similar to the example given in the MS documentation, but extracting the value from another column in the list.

Just can't work out the syntax.

  • What is the data type of CRM_URL column? – Ganesh Sanap May 7 at 3:19
0

Try this on field CRM Product Code:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "target": "_blank",
    "href":"[$CRM_URL]"
  }
}

Output:

enter image description here

Note:

  1. Make sure you are using internal name of CRM_URL field. JSON formatting works with internal names and not displaye names.
| improve this answer | |
  • I can now see and reference the internal name. However, my syntax is still incorrect, as the result is being constructed as the companyname.sharepoint.com/teams/SiteName/CRM_URL, not the URL that is in the CRM_URL field. – Texterity May 7 at 3:40
  • How the data stored in CRM_URL fields? Is it complete address with https://. Can you please add any screenshot of the data stored in CRM_URL field to see an example? – Ganesh Sanap May 7 at 3:43
  • I don't know if I add a screenshot, but the field I am referencing is a complete address e.g "intranet/Corpcoms/MMI" ... etc. The problem is that the syntax I'm trying is not creating a URL from the content of the field (which is valid) but just adding it on to the root URL of the list where it's located, which generates a valid (but incorrect) URL. – Texterity May 7 at 7:02
  • Try adding simple URL like https://www.google.com/ in CRM_URL field and try testing this JSON and let me know if you still face the same issue – Ganesh Sanap May 7 at 7:06
  • that is what I have. Maybe put it this way: in any SharePoint list, create two fields, A and B. In Column A, put the name of this Site: SharePoint Stack Exchange. In Column B, put the hyperlink of this thread: sharepoint.stackexchange.com/questions/280042/…. Now, format Column A such that when you click on the name, it launches the URL in Column B. That's what I'm trying to write the jSON script for. – Texterity May 8 at 23:06

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.