Monday, May 12, 2008

SharePoint Folders Need More Love

Folder Content Types for IT Professionals

Published in the May 12, 2008 edition of To The SharePoint

Most of you SharePoint enthusiasts probably know quite a bit about content types in SharePoint. They provide the means to organize metadata in an extremely flexible manner and provide the context for workflows, custom menus, and document templates. However, due to the document centric nature of Microsoft Office and SharePoint, the most commonly used and discussed content types are the document content types. Well, there is another lesser-known character in the content type story of SharePoint--it is the folder content type.

One reason why the folder content type is less popular is that the default SharePoint installation comes with only one of them--the Folder content type. Compared to dozens of out-of-the-box document content types, the Folder is clearly outnumbered. So let's have a closer look at this lonely hero and create a couple of folder content types so that we can find out how to use them to further enhance the user experience and data management of a document library.

To put things into perspective, let's look at how the fictional environmental foundation Rain Forest can use folder content types to improve its excising document library. The foundation staff stores all documents in a document library and they already use several document content types to support their activities. The document types are separated into two functional groups:

  • Project Documents (Additional Fields: Due Date, Assigned To)
    • Application for Grant (Word document)
    • Financial Memorandum (Excel document)
    • Formal Acceptance Document (Word document)
  • Internal Documents (Additional Fields: Contact, Status)
    • Purchase Order (Word document)
    • Invoice (Excel document)

The document library looks very familiar, and all document types are listed in the New menu:

image

The IT team of Rain Forest also defined some views based on document content type to make the filtering of each document type group easier and to be able to display content type specific fields such as Due Date and Assigned To:

image

If you are not familiar with document content types, this article shows the basics. For more information on how to create views, check out the following article.

All documents are stored in the root and occasionally employees will create folders at their discretion. However with time the clutter of folders makes locating documents really hard. All users also notice considerable slow down in view performance. After a few months, the root folder contains more than 4000 documents and is expected to grow. What can be done? This is when the little known character from our SharePoint story--the folder content type--comes in to help.

One reason for the performance hit is that folders in SharePoint have some limitations by design. For details on how the number of items affects performance, check out this article. Nevertheless if we partition the documents by financial quarters or other perpetual attributes, we can keep the total number of documents in a given folder within the high performance zone. That’s why we decide to create a folder for internal documents and project documents using the respective folder content types for every quarter of the year.

Furthermore we can provide some structure and boundaries for the employees, so that they cannot create folders anywhere in the document library. To help users locate documents, we’ll use a great feature of SharePoint, which allows us to bind views to a specific folder content type. This will provide context for each folder, so that when a user enters a folder with internal documents, the view will automatically change to display relevant metadata.

First let’s create a folder content type for each of our document groups. The steps are no different than creating any other content type. The only difference is that our content type will inherit from the Folder content type.

image

You can add specific metadata to each of the newly created content types, but for this walk-through, we’ll use the existing columns.

Next, let’s add the folder content types to our document library:

image

In addition, we would like to remove the default Folder command in the New menu, so that only our custom folder options are available. To do that, open the advanced settings of the document library and disable the New Folder option.

image

After these changes we will add our two new folder entries to the New menu.

image

Now, when a user wants to create a new folder for the next quarter, he or she will select the appropriate folder types from the New menu, and give the folder a descriptive name such as Internal Q1 2008. The process of provisioning a new folder can be automated and extended by using calculated fields or other programming techniques.

To provide the appropriate views, we create one view for the root folder and separate, unique views for each folder content type. The root view will display only folders from the newly defined content types.

image

image

Each custom folder content type will have a view that displays metadata specific to the type of document contained in the folder. These folder views are marked as default but are assigned to the specific folder content type.

image

image

Let’s see the result by creating a folder of each type.

image

You’ll notice that if you click the folder Internal Q1 2008, the view automatically will change to the Internal Documents view; similarly opening the folder Project Q1 2008 will change the view to the view Project Documents.

To add additional context sensitive behavior, you can also limit the New menu items displayed for each individual folder, so that only Internal documents show in the New menu of the corresponding folder. From the drop down menu of each folder select Change New Button Order, and hide the appropriate document types.

image

image

When you enter the folder you’ll notice that only the contextually correct New menu items exist.

image

Similarly you can hide the documents from the new menu of the root folder. Open the document library settings and in the content type section click Change new button order and default content type. Hide all but the folder content types.

image

From now on, the dedicated volunteers of Rain Forest can rest assured that they can locate documents easily and that the performance of their document library is going to be stable. Furthermore, the IT Pro of the foundation has some great ideas about how to add custom menus for each folder content type, so that actions applicable to all documents in a folder can be executed faster and in the proper context. There are also many opportunities to use item event handlers and the SharePoint DOM and workflow with folder content types to further extend the application. This SharePoint story certainly does not end here.

Mikhail Dikov is a senior software engineer at Global 360 (www.global360.com) and MVP for Microsoft Office SharePoint Server with background in CMS and BPM software. Mikhail brings more than 8 years experience in Microsoft technologies such as .NET, ASP.NET and more than 12 years of IT experience. Current interests include BPM, BI, SharePoint, .Net and AJAX. Mikhail is frequent speaker at code camps in Florida and an active member of the Space Coast Dot Net User Group (www.scdnug.org). Email: mdikov at gmail dot com Blog: www.mikhaildikov.com

31 comments:

Mike said...

Mikhail, first of all, what a great post, very clear and understandable. I've loved them before and in the scenario you're giving folders really are great. but... If you start trying to move folders around they suddenly become as evil as they were in 2003! From your profile I understand you are a developer, and via code everything seems possible, but from my point of view as a business analist I like to stay on the front of MOSS and so far I have discovered (the hard way) that you can't..

- attach workflow to folders via UI
- move folders via UI
- move folders via explorer view without losing your metadata
- have version history on folders
- show folders in data view rollups

And I think it is very important to take this in consideration when choosing folders as a solution for your information architecture.

Mikhail Dikov said...

Mike,

I cannot agree more with you, and I am glad you are bringing this up! This is exactly why I choose this title for the article and certainly the ending. Folders and Folder Content Types need more OOTB features because they are a natural way of working with documents and they may solve some performance limitations, but... Microsoft completely forgot to do that.

The items on your list are a great feature request for MS and I hope somebody is listening.

Anonymous said...

The other thing you get with folder content types is the ability to search for the folder. Content Type names are indexed so you can add

ContentType:FolderContentTypeName Value

To the search string.
I have done this in an Enterprise document library where there is a folder per customer.
See http://www.wssdemo.com/Blog/archive/2007/12/22/another-usability-tip-for-sharepoint-enterprise-document-libraries.aspx

Anonymous said...

Great post Mikhail! Thanks

Anonymous said...

Hi Mikhail,

this is a great post and I was so excited about it, I went and implemented folder content types for a client.
Only today have I discovered a really nasty bug.
If I go into a folder, click new and then save the document SharePoint saves the document with the default content type on the library. It takes the default content type and applies it to every document regardless of what content type you select from the new button!!
Has anyone else come across this?

Alana

Anonymous said...

What a brilliant and usefull article!!!

Anonymous said...

Mikhail;

Great post!

If the document library has only a top-level folder, this works GREAT!

Any suggestions on how one might handle subfolders in this scenario?

EX:

Folder1
subfolder1
subfolder2

I would like to allow users to continue using "nested" folders, but I would also like to have the nested folder be a "sub-content type" of the top-level folder.

Thoughts?

Walt

Chris Mauldin said...

Mikhail,

I've been struggling with designing a "Student File" system using SharePoint. My initial thought -- since anything could be in the Student File -- was to create a Folder for each student for ad-hoc documents that need to be attached. But there is no way I can see to use workflow to create a folder.

Then I thought "I could really just use columns on the documents if there was a su=imple way to mimic the behavior of folders"

My thought was I should be able to bring up the "Student Record" in the student list and then have a button that says "show student documents" .. BUT
I really wanted to do this without adding code sicne I want the resulting site to be maintainable by a bunch of users.

Question 1: Which way would you go? Folders or Logical Folders?

Question 2: Is there an easy to use the information on the current item to navigate to anotehr list using that data as a filter without adding code?

My issue seems so simple there should be a simple solution:

Create a list of items and allow each item to have one or more documents associated with the item.

Mikhail Dikov said...

Unfortunately folder content type does not support workflows out of the box. You can either add some pages and code to make it work (there is really no reason why it should not work) or find a different way to create a reference between the container document and the rest of the documents.

Jeroen said...

Great post, thanks. I fully agree that there are good reasons to use folders (in combination with metadata) but one issue I have with folders is that when people upload a document to a library that hides the folders in the main view, they have no option to select the folder they want to put the document into. In fact, people may not realize that the folders are there but you will end up with many documents that are stored outside of the folder structure.

Any suggestions how to make this work better?

Jeroen

Anindo said...

Great article. Can the folder display XML files ? Can we add workflow/event handlers in the folders? Thanks Anindo

Unknown said...

Thanks,

The TechNet article "planning content types" says,

"Using the Windows SharePoint Services 3.0 object model, you can customize the New command for a folder content type so that, when a user creates a new folder of that type, the folder is prepopulated with multiple files and documents based on templates stored on the server. This is useful, for example, to implement a compound document type that requires multiple files to contribute to a single deliverable document."

Do you have any insight for how to accomplish this? I want to be able to create a folder based on a specific content type pre-populated with the document templates associated with that "compound" content type.

Mikhail Dikov said...

Hi Brian,

You can use the object model to do this in SharePoint 2007, however it does require some development. In SharePoint 2010 document sets are a much better option and was designed exactly for that purpose. I am working on a blog post about document sets and as soon as I am finished I'll post the link here.

drew said...

Mikhail,
Thank for posting this, very helpful. I have attempted to create a default view for a content type but while the view is available, it is not the default for the content type. The scenario is - we have a folder-based custom content type of "contract" at the root of the doc library. inside contracts are "task orders", another folder-based custom content type. we would like the view to change as soon as a user goes into a contract, they see the list of task orders (folders) with the task order specific metadata shown. currently, they have to change the view to the task order view we created each time they go into a contract. shouldn't we be able to set the default view inside the contract content type based on the instructions in this article? Thanks!

drew said...

Well I think I answered my own question. I had to change the existing "All Documents" view to only apply to the top level of the library. As soon as I did that, the Task Order view i had created became the default. Thanks again.

Pheba Shanly said...

Dear Mike,

Thanks for your great post . I implemented the folder content type in one of our docment library where there can be many files with same meta data. So instead of adding metadata for each file I am adding that to the folder now. But one difficulty I found is that I am not able to search for folders. Is there any way to have the search functionality return folders also?

Mikhail Dikov said...

Pheba,

I would suggest looking at Document Sets in SharePoint 2010. They represent a first class container for structured and unstructured data and they are indexed by the search engine.

Mikhail

Pheba Shanly said...

Hi Mike,

We are using MOSS 2007 and I think document set feature is not available in that. Is there any way in whch we can index folders also in search engines.


Pheba

lesu77 said...

Mike,

Great article! Any chance to update the article with SP2010 in mind?

JRIESEN said...

Hmm, this sounded interesting so I applied the concept to one of my document libraries only to discover that I can no longer view the contents of the folder that uses a custom content type in datasheet view. It keeps bopping me back to the top-level folder list. I don't know about anyone else, but I rely heavily on datasheet view to do bulk editing of metadata.

Mikhail Dikov said...

@LesU - Look at document Sets in SP2010.
@JRIESEN - You are correct datasheet view is a special view (same for explorer view) that uses an ActiveX control to display data. It is very likely that by changing the folder content type it is not going to work.

Amber said...

Is there a way to link the new button order to content type folders? Fo example, I have two pricing folders, but they each have three different templates that I have loaded as a content type. Each time someone creates a pricing folder, I only want them to be able to see the appropriate pricing templates applicable to that folder when the click the new button. Thoughts?

Henriette Kringelum said...

Mikhail, I would really like to read this post, but all the screenshots are missing. Would it be possible for you to fix this?

/Henriette

Anonymous said...

No screenshot buddy, can you re-post please?

Mikhail Dikov said...

Sorry All, The article was using images that were hosted with the original publisher and they seem to have an issue. I'll try to get them back soon.

Anonymous said...

No screenshots yet!

Anonymous said...

Any chance of screenshots coming back soon? This looks like a great post but the images are very important.

Mikhail Dikov said...

I finally got to update the post with the original images. Thank you all for letting me know they did not work before, and insisting on fixing them.

Unknown said...

Mikhail - Can you recommend a solution for moving folder structures from one site to another in MOSS2007? Site Content and Structure won't allow it. Is the only solution a restore? We are trying to move a large folder w/subfolders to a different site to allow access. Thank you.

Rachel said...

If the document library has only a top-level folder, this works GREAT!

Any suggestions on how one might handle subfolders in this scenario?

EX:

Folder1
subfolder1
subfolder2

I would like to allow users to continue using "nested" folders, but I would also like to have the nested folder be a "sub-content type" of the top-level folder.

Thoughts?

Giri said...

Mikhail,

Great Post.

We were recently working on creating list templates (Include Content)of Document libraries having Custom Folder content type. What we found is a strange issue with the Folder Content Type. The metadata's of item's having the Folder Content Type is not preserved. Only Name of the folder is preserved when a new Document Library is created using the stp.
Can you please suggest way's to resolve the same.