Tuesday, July 14, 2009

How do I duplicate a list item without code?

By Roi Kolbinger - SharePoint Consultant
KWizCom Professional Services – http://www.kwizcom.com/

Did you ever wish to copy an Item to the current list several times? What is the best way to duplicate a list item? Can it be done without code?

There is an easy, effective way and no – you don't need code! Here's how:

All you need to do is to create two new columns and SPD workflow.

Step 1: Create columns

Name the first new column you create according to the number of copies you want to make. When defining the type of information that will be in the column, choose "number". This column is where you will define the number of copies you want to create.

Name the second column according to the number of copies you want, minus one. Define the type of information that will appear in this new column as "Calculated" (this gives a number which is the result of a calculation based on a different column).
The calculation we will use here will take the first column and subtract from it -1.
The formula to use for doing this is =[number of copies]-1 like so:

Step 2: Create a new workflow at the SPD

Open the site at the SPD and then create a new workflow.
Give the workflow a name and select the list from which you desire to copy the Item. Then select your workflow start options. It is best to choose: "automatically starts the workflow whenever the item is been changed". This will renew your workflow each time the item has been updated and/or edited and insure that the calculated result is always accurate.

Next, define the step of the workflow – select "Number of copies" greater the zero.

And then, define two actions:
1) Update your item: "Numbers of copies" is will be "Number of copies minus one".

2) Create a new item in the list that duplicates the columns taken from the original item. Do not include the "Number of copies" column! If you do an infinite loop will be created.

Now when you go to an item that you wish to duplicate, all you need to do is edit the item and write the numbers of copies that you want to make in the "Number of copies" column and your copies will be made! Easy and simple with no code necessary at all!


Sriram said...

Say, how do I activate this workflow from editform.aspx (or dispform.aspx) if I want to?

Anonymous said...

I followed the steps (thank you), but it only makes one copy and not the number of copies I specify. Any ideas where I went wrong. Much appreciated! Thanks for your post!

Roi Kolbinger said...

I think, that Workflow can not call himself.
Check that you set the Workflow is selected "automatically starts the workflow whenever the item is been changed".
If it is set, then checks to see if there are failed in Workflow, maybe it will help you.

Anonymous said...

I created this workflow in SharePoint Designer 2010 for a SharePoint 2010 list and found that I also see one item copied even though I put a number greater than 1 in the "Number of Copies" field. I checked the workflow settings as you suggested and also found that the workflow did complete successfully, without errors. I was wondering if you have any other suggestions. Thank you in advance.

Roi Kolbinger said...

Try to add a comment (to the field of workflow history) and try to see what point he was unable to process

Ali said...

Having the same issue with Sharepoint 2010. Only one row is created no matter the value of the 'Number of Copies' field. Roi would your solution work differently on SP 2007 vs SP 2010?

Shai Petel said...

Hi Ali,

The designer is different but you should be able to do the same in both 2010 and 2007.

Can you share your workflow designer image?

Anonymous said...

I would really like to do this. I am completely new to SPD 2010. Is there any chance you could flesh out the details step by step? For example, I don't know how to select the right fields.

Also, is there a way to have the attachments attach to the new copies?