Can i define a default value for a HyperLink site column to include the item ID

john john 1,021 Reputation points
2021-09-13T21:53:27.247+00:00

i have the following column of type Hyperlink and i want its default value to include a url with the Id of the item, i tried to define the format inside the JSON but it did not work, as follow:-

131660-masterid.png

So can anyone advice how i can define a default value for a HyperLink site column to include the item ID?

Microsoft 365 and Office SharePoint For business Windows
{count} votes

2 answers

Sort by: Most helpful
  1. Echo Du_MSFT 17,316 Reputation points
    2021-09-14T07:38:57.37+00:00

    Hello @john john ,

    We recommend that you create a Single line of text column and then convert this column into hyperlink formatting.

    Please the following steps:

    1.Create a Single line of text column in the list

    131873-c1.png

    2.Format this column

    131826-c2.png

    3.On the Formati column panel, click on Advanced mode

    131891-c3.png

    4.Use the below JSON:

    {  
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",  
      "elmType": "a",  
      "txtContent": "@currentField",  
      "attributes": {  
        "target": "_blank",  
        "href": "='https://****.sharepoint.com/sites/sitename/Lists/listname/AllItems.aspx?FilterField1=MasterID&FilterValue1='+[$ID]"  
      }  
    }  
    

    131815-c4.png

    131885-c5.png

    Thanks,
    Echo Du

    ===========================================

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Ganesh Sanap 211 Reputation points
    2021-09-15T13:56:56.077+00:00

    SharePoint hyperlink columns does support the JSON column formatting.

    Check list of supported columns at: Supported column types

    @john john ,

    For answer to your question, check my answer given at: Can I define a default value for a HyperLink site column to include the item ID

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.