JSON column formatting not recognizing column reference

Cashion, Colby 6 Reputation points
2021-02-22T18:51:08.333+00:00

Hello,

I am trying to add a custom hyperlink to a Sharepoint list column, that changes the URL based on another value in the column. Currently my formatting is the following

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "View Evidence",
"attributes": {
"target": "_blank",
"href": "='https://intelsat.sharepoint.com/sites/SOC3Audit/2021 SOC 3 Audit document repo/' + [$RequestNum]"
}

}

Currently, in the href, the RequestNum column is not getting picked up, and the link always directs to the URL without the column included at the end. I've tried to add a column name to dynamically appear in the txt Content as well, but the link just appears in the list as "View Evidence for [$RequestNum]".

I have tried a variety of different formats for the column name but none have worked so far. Is there anything in SP Online that needs to be enabled for this to work? This is a Modern list.

Thanks,
Colby

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Du-MSFT 44,311 Reputation points Microsoft Vendor
    2021-02-23T10:06:46.85+00:00

    @Cashion, Colby
    Based on your description, I understand that you create a Hyperlink column and a RequestNum column. You want to the value in the Hyperlink column becomes a hyperlink according to the RequestNum column.

    Here’re steps:

    1.Create a text column named Hyperlink.
    2. Create a text column named RequestNum。
    3.Use following Json formatting in the Hyperlink column.

    {  
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",  
    "elmType": "a",  
    "txtContent": "View Evidence",  
    "attributes": {  
    "target": "_blank",  
    "href": "='https://intelsat.sharepoint.com/sites/SOC3Audit/2021 SOC 3 Audit document repo/' + [$RequestNum]"  
       }  
    }  
    

    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.

    0 comments No comments