Sample: Link to parent documentset of a file

Using documensets is a fantastic way of organising your documents, benefits of documentsets include:

  • Folder-like behavior,
  • metadata filtering towards you documentsets,
  • different default views for the library and the contents of a documentset,
  • the optional metadata syncing from the documentset towards the documents contained within

This post is not about setting up the documentset in a library, but what we do want to do here, is to create a column that shows in which documentset a file is stored…

Now why would that be useful?

Imagine a library containing documentsets with an additional view which shows all the recent documents stored within the documentsets. So not the recent documentsets, but only the recent files.

Create the Recent documents-view

You can easily do this using the classic experience for changing views.
Let’s assume we have a library with a documentset content type called “Project Folder”.

  1. Select the current view and choose Save view as
  2. Enter a name that would make sense, like, “Recent Documents”
  3. Click on ethe view and choose Edit current view
  4. Go to the Folders-section and select Show all items without folders
    Although this will start showing the documents, you still get to see the documentsets too.
    So, in order the hide the documentsets:
  5. Go to the Filter-section and select: Content Type is not equal to Project Folder
    Where Project Folder is the name of the documentset content type

Create the Project-column

Now let’s make sure we can see to which project every document belongs.
We therefore need to create a new column that is going to contain the format that allows us to see the documentset-name.
It is important to note that we are only applying a column format that shows the documentset-name, we are not going to fill the column with any data because that should involve some triggered-scripting.

  1. Go to the “Recent Documents”-view
  2. Click on Add column, and select Single line of text
  3. Enter a useful name for this column, for example: “Project”
  4. Click on More options and deactivate “Add to all content types”
    By doing so, this column will not show up in any properties-form.
  5. Now the column is created, we can apply the format that will generate the name and the link.
    Click on the column-header and select Column settings > Format this column
  6. Click on advanced and copy-paste the code below
  7. Click on Save to save and close the column format.
  "$schema": "",
  "elmType": "a",
  "txtContent": "=substring(substring([$FileRef], 1, lastIndexOf([$FileRef],'/')),lastIndexOf(substring([$FileRef], 1, lastIndexOf([$FileRef],'/')),'/')+1,1000)",
  "attributes": {
    "href": "=replace([$FileRef], '/'+[$FileLeafRef],'') + '/'"


Documentsets are great, and with some extra attention we can make them even more user-friendly.

Update: I have updated the code based on a tip from The Chris Kent | Quick Fixes, Workarounds, and Other Neat Tricks