Hi @Raki ,
Welcome to Q&A Forum!
According to my understanding, FileRef and FileLeafRef are built in fields of SharePoint.
FileLeaRef: Identifies a field that contains information about the server-relative URL for the file node that is associated with the specified SharePoint Foundation object.
FileRef: Identifies a field that contains information about the server-relative URL for the specified SharePoint Foundation object.
This JSON only works at the document level and not at the folder level. So when you clicking the link at folder level, it's normal to throw an error.
Thanks,
Echo Du
=======================================
Update Answer ====================================
Hi @Raki ,
Please follow the steps:
1.Create a Single line of text column named [Download]
2.Use the below JSON formatting for [Download] column
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "a",
"txtContent": "[$FileLeafRef]",
"style": {
"cursor": "pointer",
"visibility": "=if(((indexOf([$ContentTypeId],'0x0120')) == 0),'hidden', 'visible')"
},
"attributes": {
"target": "_blank",
"href": "=@currentWeb+'/_layouts/15/download.aspx?sourceurl='+[$FileRef]"
}
}
Thanks,
Echo Du
====================================
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.