Link SharePoint List to a Document Library

SharePoint Lists are great for tracking activities. There are many scenarios where you may want to store a collection of documents for each List item. In this blog I explain how to use Column formatting to create the link to the documents related to a List item.

In this example, we have a List that will track enquires and a Library with a folder per enquiry. Each enquiry will have a unique number and the library will contain a folder with the same number. to keep it simple, I will use the Lists ‘Title’ field, but you could use a different value by adding a number generator or entering a unique value in the List form.

Steps

Create a List with the various fields you want e.g. details of the enquiry, type of enquiry, dates etc.

Create a PowerAutomate Workflow that creates a folder in the Document Library when a new item is added to the List. In this example, when an Item is created in “MyList”, the second step creates a folder in the “Clients” Library using the List items Title as the Folder name.

To create a hyperlink from a SharePoint List to the corresponding folder in a Document Library, follow these steps:

  • Add the following JSON column formatting to the column, replacing URL in the “href” line with your URL (Library URL)
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "target": "_blank",
    "href": "='http://xxxxxx.sharepoint.com/sites/sitename/libraryname/' + @currentField"
  }
}

Done! Now every time a new List item is created, Power Automate will create a folder using the List items Title as the folder name. The calculated column will contain a hyperlink, that takes you to the corresponding folder where you will see existing documents and can drag and drop other correspondence.

Creating an item in the SharePoint List for Joe Bloggs, creates a Hyperlink

Clicking the Link takes me to the Clients document library with a list of documents for the client.

I use this technique for various scenarios including, customer enquires, client folders, incident management and certification tracking.

I hope you find this helpful.

5 thoughts on “Link SharePoint List to a Document Library

  1. this worked perfectly, however for me the link in the list does not actually take me directly inside the corresponding folder, it just brings me to the document library itself. Is there a way to have the link bring me inside the correct folder?

  2. Hi Mary, the value in the List needs to be the name of the folder e.g. if the folder is called 12345 then the List needs to have the same value. The JSON formatting will append the value to the end of the URL. I hope that helps.

    1. I realized it was actually my URL that was the issue and it works now thank you. This was actually the most straightforward way to accomplish this task, after hours of attempting various methods that all ended in failure. The only thing I did not consider is that if I need to change the title of the list item for some reason, the folder name does not update automatically to match.

      1. Thanks for the update Mary, I am glad you resolved the issue. You are right about the title, in some scenarios you can use a different column to store the folder value. That works as long as the value is unique.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s