Calin Tatar

C#.NET, VB.NET, WPF, SILVERLIGHT, SQL, WSS, MOSS
posts - 5, comments - 27, trackbacks - 0

My Links

News

Archives

Post Categories

C#.NET

Links

VB.NET

Sunday, June 07, 2009

Automatically add Sharepoint subfolders when adding a new Folder Content Type

Last week I was asked on one of my CodeProject article, about how to implement a Sharepoint feature that will automatically add subfolders to a parent folder in a document library.

To add subfolders when a new Folder(or derived Content Type from Folder) was created, we have to write a feature, that will handle the ItemAdded event. When this event gets fired, we can get the current folder item and add subfolders to it.

The following feature adds subfolders( the ones from folders array) when a new Project Folder is created.

SubFoldersCreatorFeature

Basically, what the above method is doing is:

- we get the current document library that we are working on.

- test if the current Item is derived from our Content Type; with this we can restrict the feature to work only on some of the folder content types

- by getting the url of the current folder, we can add a new folder on the current SPDocumentLibrary.

Enjoy!

Calin Tatar

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Sunday, June 07, 2009 4:48 AM | Feedback (25) | Filed Under [ UI Automation MOSS 2007 WSS 3.0 ]

Powered by: