Forum Discussion

Kris Toledo's avatar
Kris Toledo
Copper Contributor
Oct 05, 2023

List to have a link to document library

Hi,

I have a list and i wanted to have a column that will link me to a document library folder. This link once pressed should show the user all the files within that folder. I have tried to create a lookup column but it was moving the link to this view.

 

Would it be possible to have a view like this?

 

 

  • Kris Toledo 

     

    Try this:

    1. Create a new text column in the SharePoint list
    2. Every time you add a new list item, you have to enter the relative folder path in this text column. For example:
      • if you have the folder hierarchy like: library>folder1, use relative path in list column like folder1.
      • if you have the folder hierarchy like: library>folder1>folder2, use relative path in list column like folder1/folder2.
      • if you have the folder hierarchy like: library>folder1>folder2>folder3, use relative path in list column like folder1/folder2/folder3.
    3. Then format your list column using JSON like: 

     

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

     

     

    Instead of @currentField, you can also use the internal name of your text column in JSON. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online? 

     

    Similar threads:

    1. Filter a document library from a list 
    2. Creating a Link to Filtered Document Library using JSON Column Formatting 
    3. Link from SharePoint Library to list item 

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

  • Kris Toledo 

     

    Try this:

    1. Create a new text column in the SharePoint list
    2. Every time you add a new list item, you have to enter the relative folder path in this text column. For example:
      • if you have the folder hierarchy like: library>folder1, use relative path in list column like folder1.
      • if you have the folder hierarchy like: library>folder1>folder2, use relative path in list column like folder1/folder2.
      • if you have the folder hierarchy like: library>folder1>folder2>folder3, use relative path in list column like folder1/folder2/folder3.
    3. Then format your list column using JSON like: 

     

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

     

     

    Instead of @currentField, you can also use the internal name of your text column in JSON. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online? 

     

    Similar threads:

    1. Filter a document library from a list 
    2. Creating a Link to Filtered Document Library using JSON Column Formatting 
    3. Link from SharePoint Library to list item 

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

Resources