1

I've used the multi line text column in SharePoint, where I want the fields to be clickable.

and I used the following JSON:

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

but I received the following error when I click on the link:

Sorry, something went wrong An unexpected error has occurred. TECHNICAL DETAILS GO BACK TO SITE

and this the link:

https://universityoftripoli.sharepoint.com/sites/RC1/Lists/20201/%3Cdiv%20class=%22ExternalClass845D4BA456454283A4484A971DA3DE91%22%3Ehttps://universityoftripoli-my.sharepoint.com/personal/rcc_uot_edu_ly/Documents/Apps/Microsoft%20Forms/%D9%85%D8%B9%D8%A7%D9%8A%D9%8A%D8%B1%20%D8%A7%D9%84%D8%AA%D8%B5%D9%86%D9%8A%D9%81%20%D8%A7%D9%84%D8%A8%D9%8F%D8%B9%D8%AF%20%D8%A7%D9%84%D8%AF%D9%88%D9%84%D9%8A%20(Copy)%203/Question/%D8%AF.%D8%B9%D8%B2%D9%8A%D8%B2%D8%A9_AHLAM%20ELKHESHEBI.pdf%3C/div%3E

and my original link is:

​https://universityoftripoli-my.sharepoint.com/personal/rcc_uot_edu_ly/Documents/Apps/Microsoft%20Forms/%D9%85%D8%B9%D8%A7%D9%8A%D9%8A%D8%B1%20%D8%A7%D9%84%D8%AA%D8%B5%D9%86%D9%8A%D9%81%20%D8%A7%D9%84%D8%A8%D9%8F%D8%B9%D8%AF%20%D8%A7%D9%84%D8%AF%D9%88%D9%84%D9%8A%20(Copy)%203/Question/%D8%AF.%D8%B9%D8%B2%D9%8A%D8%B2%D8%A9_AHLAM%20ELKHESHEBI.pdf

enter image description here

This is a print screen of the Inspect Element

2 Answers 2

1

Go to list settings -> In the Columns section, select the multiple lines of text column -> Specify the type of text to plain text.

In the column formatting, set code as following picture shows. enter image description here

0

Somehow your JSON code is adding list URL at the beginning of newly created link by JSON. That's why you are facing this issue.

Try using below JSON code. This is working fine for me:

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

Microsoft documentation: Use column formatting to customize SharePoint

Update from comments:

Check the link generated using JSON by hovering over link or by inspecting the link element using browser's developer tools. In my case, link is generated correctly like below:

enter image description here

4
  • I am still facing the same error when I;ve used this code { "$schema": "developer.microsoft.com/json-schemas/sp/v2/…", "elmType": "a", "txtContent": "=if(@currentField, 'Click Here', '')", "attributes": { "target": "_blank", "href": "@currentField" } } Dec 18, 2020 at 9:06
  • Can you please inspect (using browser dev tools) the link element created using this JSON and check how the href property is generated. Check image in my updated answer for reference. Dec 18, 2020 at 9:20
  • I do not have experience in using the browser's developer tools, can I send you access to help me thanks in advance Dec 18, 2020 at 9:46
  • Just hover over the link created by JSON and you can see the link generated at the bottom left of page (like the link at bottom left corner in the image I shared). And if you want to inspect the link element like another link shown in image then refer this link. Dec 18, 2020 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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