OPEN TO WORK

Available for new opportunities! Let's build something amazing together.

Group Items on Their Folder Name Inside a SharePoint Library

Documents Grouping Views
post

This post is over a year old, some of this information may be out of date.

Some time ago a client asked me if you could create a view where all the documents are grouped on the folder name. The folders were used to set the permissions on documents, so they could not be removed.

As you probably will know, folders could not be used in views to group documents. You could only group documents on their metadata.

Show image Group Documents
Group Documents

A possible solution could be to add a new metadata field to the content type and manually add the folder name as the metadata value. It is very easy to add and requires no custom development, but it requires an extra manual step from the document creator.

This manual step can also be automated by a SharePoint 2010 Document library functionality called Column default value settings. It can be found on the document library settings page under the General settings section.

The Column default value settings enable you to define a default value for a metadata column per folder.

Show image Default column value
Default column value

Approach

  • Go to the document library settings;
  • Create a new column called: Folder name (Single line of text);
  • Click on Column default value settings under the General settings section; {{< caption-new “/uploads/2011/09/091611_1231_GroupItemso3.png” “Culumn default value settings” “data
    /jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAHCAIAAAC+zks0AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAqUlEQVR4nEWM2Q6CMBQF+/8fpzGySIIgCtaW7sttC4JGjHFy3iZnkOCMPMhIx5HSB8Yjpeu6vn4g44PQTlqQFoR2QlsfZ59mAzOkJ8I69TpdROhEaFnAZiImERNbDtxNiLl0FWGQsZehZTCouPzbL0Tt1PHQqzio2DDAOn3Fug0RBTWxNwEDdw2xdwnLsswbn/e168o8b+rzfrevyrI6VUVeZFl2PByd928mJMR2OvbFzAAAAABJRU5ErkJggg==” “191” “131” >}}
  • On the left side you will see your folders, and on the right site the columns for which you could give up a default value; {{< caption-new “/uploads/2011/09/091611_1231_GroupItemso4.png” “Folders, columns” “data
    /jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAACCAIAAADuA9qHAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAPklEQVR4nC3BQQ5AMBBA0d7/gnaSRixIDdOaxoj5bLyXxmkZsqxiRW2vJtr65e73aR0iyTYfVYEn4P0BEQF83Yo5qG2wV+oAAAAASUVORK5CYII=” “545” “88” >}}
  • Click on the folder name, and after that on the column name; {{< caption-new “/uploads/2011/09/091611_1231_GroupItemso5.png” “Default column value” “data
    /jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAECAIAAAA4WjmaAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAfUlEQVR4nBXBSwrCMBAA0BzfK2TVhbQuipaCRfyAHsOFu4KbJpNPq5mZ6ER8TzX9aTdcusO1P97a/bneDtWm0+tWV/VKNwp8IEw5cxEppcwxxOAxJWEc7aKWNzIzEnHORATOOx/Ahdcc7+OkkD8i8pU/RDTGAIAF5+z0eNofR1lqFB6qiu8AAAAASUVORK5CYII=” “605” “256” >}}
  • Click Use this default value, and fill in the folder value and click OK;
  • Repeat this process for each folder. Now when you upload a document to a folder, the **Folder name column **will automatically get the default value.

To prevent users being able to fill in their own value, you could hide the Folder name column from the new and edit forms.

Show image Hidde column from forms
Hidde column from forms

Result

Show image Group by on folder name
Group by on folder name

Attention: SharePoint Foundation

The Column default value functionality is not available in SharePoint Foundation.

Report issues or make changes on GitHub

Found a typo or issue in this article? Visit the GitHub repository to make changes or submit a bug report.

Comments

Elio Struyf

Solutions Architect & Developer Expert

Loading...

Let's build together

Manage content in VS Code

Present from VS Code