Skip to main content
added 300 characters in body
Source Link
Ganesh Sanap - MVP
  • 46.4k
  • 22
  • 31
  • 63

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

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

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

Source Link
Ganesh Sanap - MVP
  • 46.4k
  • 22
  • 31
  • 63

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