views:

480

answers:

2

Hello,

I have a question. I hope someone can help me out on this one.

I'm setting up a sharepoint-site for a client of ours. There's a document library ("Customers"), in which every Customer has one folder (=customername) with 4 sub-folders. The subfolders are always the same ("Technical Information", "Documents", "Security information" & "Hardware"). What I would like to happen is whenever a new folder is created in the library (that is whenever a new customer is entered), the 4 subfolders are automatically created in that new folder. I wanted to do this in a db-trigger & I found out that for every folder in the library, a record is created in the db-table dbo.AllDocs. The thing is: - there are about 63 columns in that table & the purpose off some of them is not clear to me. - actually this isn't such a great id since writing in the WSS Content db via a script is
anyone got any idea's?

Thanks in advance for feedback!

+5  A: 

Its is not recommended (I would say Should not) to touch the SharePoint DB. Always do your customization through the SharePoint UI or the ample number of other options you have with the SharePoint. For your case I would recommend to create a New Event Handler that will be attached to the Doc Lib. When you create a Folder (Top Level Customer) you need to create the respective sub folders. You also make sure that the Event Handler doesn't get trapped in the Recursion while creating the sub folders. Refer the below links to Event Handler 1 2

Kusek
Never ever write to the SharePoint DB! Not supported by MS. Also haven't heard much good about triggers either.
Alex Angas
Thank for the information! I will try and figure out how to create an event handler. Regards,Philippe
A: 

I would suggest you to add this functionality in a feature. For example could you add an extra link in the New drop down menu item in the document library toolbar called "New customer". In the code for this command, create the 4 folders programmatically.

This would mean that you don't have to worry about determine whether you are creating a customer folder or a normal folder in your event handler.

Magnus Johansson
Thanks for the info!!