none
How do I automatically add sub-folders when I create a folder in a List or Document Library?

    Question

  • Hello,

    I am trying to create something that is quite basic in principle, but seems to be causing me some grief, whether I try to do it using SharePoint itself or in SharePoint Designer.

    I have to create a list/folder structure, so that when a user clicks 'New' in the List area, it adds a new folder, which is pre-populated with a defined set of sub-folders/files.

    I have currently created a list called 'Cases' and added a Site Content Type called 'New Case', which I have set in the List Settings as the default 'new document' type. However, when the user creates a new folder, it is empty and I want it to be that I do not have to manually add the folders each time someone creates a new case.

    Any ideas on how I would go about pre-populating a new list item in this case?
    • Moved by Mike Walsh FIN Tuesday, April 13, 2010 3:10 AM needs programming (From:SharePoint - Setup, Upgrade, Administration and Operation (pre-SharePoint 2010))
    Monday, April 12, 2010 1:21 PM

Answers

  • Hi,

    You cannot do this directly in SharePoint.  You would need to carry out coding to intercept when a NEW item is being added and do this against the SPLIST list object - then you can use that to programatically add an item to the list including carrying out other things like creating folders / files etc.

    You would use the Add() method of the Items collection which creates and returns a new SPListItem. Then, you would initalise the new item with some values, for example, setting the  "Title" property of my item, carrying out the other things I mentioned above, then using Update() to push the changes to the database.

    If you are a developer then you'd have the necessary tools to do this and there is copious information on how to carry out using SPLIST item - for example, here's such an article:

    http://amitkumarmca04.blogspot.com/2009/07/what-is-use-of-splistitemsystemupdate.html

    and if you are not, or you've not heard of using SPLIST then you have a lot of learning to do - here's a snippet from MSDN explaining how to use Add on SPLISTITEM

    http://msdn.microsoft.com/en-us/library/ms467435.aspx

    Hope this helps

    Geoff

     

    • Marked as answer by Freya-San Tuesday, April 27, 2010 7:17 AM
    Monday, April 12, 2010 1:37 PM
  • You will need to create a custom workflow that is associated to the content type. Have a look at this post on how to initiate the custom workflow: http://www.codeproject.com/KB/sharepoint/MOSS_FolderContentTypeWF.aspx
    • Marked as answer by Freya-San Tuesday, April 27, 2010 7:17 AM
    Tuesday, April 13, 2010 4:27 AM

All replies