Forum Discussion

RogueWolf1985's avatar
RogueWolf1985
Copper Contributor
Jul 23, 2020
Solved

How do I format a SharePoint list column input to complete a URL?

Hello I am relatively new to SharePoint and JSON code.  I am trying to design a list column so that when a user types in the entry the entry is then automatically converted into a URL.  For example, ...
  • ganeshsanap's avatar
    Jul 24, 2020

    RogueWolf1985 Yes, this is possible. You can use below JSON code on your ProjectName column:

     

     

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

     

     

    Also, if "https://company.sharepoint.com/sites/ParentSite" is the same site where you are adding this JSON code then you can also use "@currentWeb" instead of hard coding the site URL in JSON like below:

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

    Use column formatting to customize SharePoint 


    Please click Mark as Best Response if my post helped you solve your issue. This will help others find the correct solution easily. It also closes the item. If the content was useful in other ways, please consider giving it Like.

Resources