tags:

views:

336

answers:

2

I have a document library with about 50 available content types. This document library is divided into several folders. When a user cliks the "New" button in a folder, all available content types are offered. I need to limit the content types according to the folder. For example, in the folder "Legal" a want to have only content types containing legal documents. I tried to use the UniqueContentTypeOrder property of SPFolder but it does not work. What is wrong?

private void CreateFolder(SPFolder parent, string name) { SPFolder z = parent.SubFolders.Add(name); List col = new List();

        foreach (SPContentType type in myDocumentLibrary.ContentTypes)
        {
            if (ContentTypeMatchesName(name, type))
            {
                col.Add(type);
            }
        }
        z.UniqueContentTypeOrder = col;
        z.Update();
    }
+3  A: 

Have you looked at this article by Ton Stegeman?

Magnus Johansson
This link is dead-on, thanks! You might want to mention the author Ton Stegeman's name as well...
barryd
Than you. The solution is the same as my code. It just did not work for me for unexplainable reasons . After restarting the server everything is suddenly fine.
danatel
A: 

I think Magnus' answer will be exactly what you need but why are you storing to many content types and document types in one library? Wouldn't it make more sense to have more than one document library? this would make it much more easily managed.

Mauro