Donnerstag, 3. Mai 2012

Move items into a SharePoint list folder

How-To: Move items into a folder using a SPD workflow

In one tutorial I explained how to create folders using a SPD workflow. Only having folders when you still need to create all items in the according folder manually doesn't make too much sense.

So I figured out how to move items into folders using SPD workflows.


What do you need?

All you need to do before moving items is to assign the folder content type to the according lists. How this can be done is explained here.


Let's get it done

Actually there is no standard workflow activity moving items. So we are going to use the "Create List Item" activity. You might think "Copy List Item should also work.". Well, actually, it does not work for this purpose since you cannot change any fields of the item to be moved.

So here is how you move items:

  1. Add the "Create List Item" activity.
  2. Of the new item, set all field values to the ones of the current item.
  3. Additionally, set the field "Folder" to the name of the folder where the new item should be placed in. (This is where "Copy List Item" would fail.)
  4. Afterwards delete the current item, so only the new one stays present.
Please note: The folder for the new item must already exist.
Of course you can also create completely new items inside a folder. :-)

8 Kommentare:

  1. Hi,
    Thanks for articles about Sharepoint.
    But this trick don't work with libraries. There are no Folder field at all.
    Did you know how to move items in folders in libraries?

    AntwortenLöschen
    Antworten
    1. Hi OlegT,

      This is also pretty simple:

      Instead of deleting and creating the document again, you can simply do the following:

      Select the "Update Item" activity in the workflow. A new window pops up.

      There make sure "Current Item" is selected at the top.

      Then click on "Add" at the right. Here you can select a field and its new value.

      Select "Path and Name" as the field.


      Then beneath that click on the "..."-button which opens a new window.

      If you have a static folder you can simply type in "myFolderName/" (the slash is important!) and add a lookup (button in the bottom left), here you have to select the name of the current Item and click on Ok.

      That's it!

      The document will be moved into the according folder (make sure it exists already).

      Of course you can also define the folder name dynamically by replacing the "myFolderName" with an additional lookup.

      Löschen
  2. Hi

    I have tried what you suggested with libraries but it does not work. I have tried various ways like relative path and full path but can't get it to work at all. Do you have a working example of the code?

    Thanks

    AntwortenLöschen
  3. Is there a way to use this Workflow while allowing it to start when the item is created? When I select that option, errors are found because in theory the new item would create a new item would create a new item would create a new item... and so on. Thank you Kevin!

    AntwortenLöschen
  4. Hi,
    Is there a way were we could use sharepoint designer to create a workflow when an email comes into the site mailbox in sharepoint online 2013. I need to check for cople of conditions. Email has an attachment -> Check the subject line of the email and move it into the corresponding folder if present, if not create a new folder and move it into it.

    AntwortenLöschen
  5. Very good, tested this LepideMigrator for Documents tool (http://www.lepide.com/lepidemigratordocuments/) which helps to move items list to SharePoint folder and migrates to data from file server to SharePoint Online (Office 365) and allows to migrate bulk content and provides instant real-time progress reports to ensure on-time completion.

    AntwortenLöschen
  6. i have a document library called "DocLib". it has multiple sub folders(created manually) in it.

    DocLib ->Folder1

    DocLib ->Folder2

    DocLib ->Folder3

    and further "Folder1" has one more folder called "Archive"(created automatically though javascript). so basically it looks like-

    Folder1 -> Archive1

    Folder2 -> Archive2

    Folder3 -> Archive3

    consider this. I upload 20-25 documents inside folder1 every month. what i want is, after every 1st date of the month, those documents should move inside "Archive1" sub folder. same goes with the other folders. like documents from "folder2" should move to sub folder "Archive2" of the "folder2" so on & so forth.

    is it possible to do so ?Can it be done using workflow or java script ?

    thanks.

    AntwortenLöschen
  7. Only Problem - if the list item has an attachment - the attachment does not create with the new list item

    AntwortenLöschen