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

Group Items on Their Folder Name Inside a SharePoint Library

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;
    Show image Culumn default value settings
    Culumn default value settings
  • 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;
    Show image Folders, columns
    Folders, columns
  • Click on the folder name, and after that on the column name;
    Show image Default column value
    Default column value
  • 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.

Comments

Back to top