Donnerstag, 3. Mai 2012

Create folders using a SPD workflow

How-To: Create folders in a SharePoint list using a SPD workflow


As you may know SharePoint lists are only supporting a limited number of items. For example, only 5000 items can be retrieved in a view. To get your list structured the usage of folders is recommended.

In the future I might provide a tutorial for activating the option to manually create folders in a list, though this is actually pretty simple. I will post a link here if I do so.

But you may ask "What if I don't want to create the folders manually?".Well, you could, of course, write your own application or event receiver creating all the folders for you. Still some of you might feel uncomfortable programming stuff for SharePoint or in general.

Well, there is yet another solution for our folder problem in SharePoint, at least in SP 2010.
All you need is the SharePoint Designer 2010 which can be downloaded from Microsoft directly. It enables you to create custom workflows which go far beyond what SharePoint provides out of the box.

After installing and setting up SPD, you can move on creating your automated folder creation workflow using my tutorial.


Now let's get it done

 

Prepare the list

For a custom workflow being able to create folders, you need to assign the folder content type to the list. To do so, you have two options: using the SharePoint Designer or your browser.

I will explain the more easier one (in my opinion), using the browser.

  1. Open the list in an internet browser. There will be an option bar at the top.
  2. Select "List" and choose "List Settings" in the new ribbon.
  3. Now, if you haven't done so already, click on "Advanced Settings", activate the option "Enable management of content types" and click on "OK".
  4. Head back to the list settings.
  5. Now there is a new section listing all content types for the list. Click on "Add from existing content types".
  6. In the new page, select "Folder Content Tpes" from the dropdown menu.
  7. Add the content type named "Folder" to the list content types by selecting it and clicking on the arrow pointing to the right.
  8. Click on "OK" to save the new assignment.
Please note: Still the folder won't appear in the content type section of the list settings, which I'm not sure of whether it is a bug or not. That also means that you cannot remove the folder content type from the list.


Create your workflow

As your workflow probably will have a different purpose than the one I made, I will only explain the important part. :-)

A folder is generally just a list item. So we are going to build on that.

  1. To create a folder, choose the action "Create a list item".
  2. Click on the blue part to open a window asking for some information.
  3. Choose the list where the folder shall be added from the dropdown field.
  4. If your list has multiple content types, a field to assign a value to, will automatically be added. It is called "Content Type ID". If it is not present, click on "Add" to add this field.
  5. For the value of this field you will have a dropdown selection from which you have to choose "Folder".
  6. To give the folder a name, also add the field "Title" and give it a value of you choice.
Please note that this value for "Title" has to be unique, so you might have to change your lookup or logic accordingly. That means that you should implement a check if a folder already exists, explained here.

Final notes

Of course just having the folder might not be enough. So check out my tutorials on how to place a list item inside a folder and how to set permissions for a folder, both using SharePoint Designer Workflows.

Kommentare:

  1. Hi;
    I'm stuck at step 6 and 7 in Prepare the List. Folder is not a choice. I went to create a new content type, but Folder was already there. I just does not show up to be selected.
    I tried these steps with both newly created lists and existing lists and Folder is not available to select in any of them.
    Any ideas on how to get Folder to show up in the pick list?
    Thanks

    AntwortenLöschen
    Antworten
    1. Hi,
      You could try to assign the content type in the SharePoint Designer, maybe it shows up there.

      Also you can try to activate folders for the SharePoint list.
      In the browser head to your list, select "List Settings", then "Advanced Settings". There should be an option "Make 'New Folder' command available. This might be the trick.

      If that also doesn't work, you could try to create new content type and select the "Folder" content type as its parent. Then you can select the new content type in your list. But that's something I'm not pretty sure of.

      Please tell me if it worked.
      Regards,
      Kevin

      Löschen
  2. Is there a way to do the same for a document library?

    AntwortenLöschen
  3. Thanks for sharing this information. I have just signed up for a free SharePoint 2013 site with http://www.cloudappsportal.com.

    AntwortenLöschen
  4. I started on SharePoint around and have gone through the same denials, acceptance, and now really loving the vast landscape of SharePoint. There is so much to learn, so many real world problems to solve, and so many fantastic ways to solve them.
    sharepoint 2013 administration certification

    AntwortenLöschen