A common SharePoint customization request is to copy or move items and documents between lists.  This can be accomplished without development by creating a workflow using SharePoint Designer (SPD).  With this approach, you may encounter issues with list item fields not copying or copying intermittently.  This article will explain how the copy list item activity works, what can go wrong and how to troubleshoot and resolve the issues.

About SPD Workflows

If you are not familiar with SPD workflows, here is a quick primer on how to create a workflow that copies a list item to another list.  Open the site and select File > New Workflow.  Select the source list and set the start options.  Note in this example, the workflow executes when a new list item is added.

Define your new workflow

The workflow consists of steps which have conditions and actions.  In this example, there are no conditions, only an action to copy the list item:

Copy List Item Step

Configure the action to copy the current item in the source list to the target list and click Finish to associate the workflow with the source list.

Configure Copy List Item Activity 

Add a new item to the source list and you can see the outcome of the workflow:

Copy List Item Source

The item was copied to the target list:

Copy List Item Target

How the Copy List Item Activity Works

The copy list item activity iterates through all the fields in the source list and tries to find a match in the target list.  The fields are considered compatible for copying when the following is true:

  • The source and target field names are the same.  It compares the field name you see in the browser (SPField.Title), not the internal/static name (SPField.InternalName)
  • The source and target field are the same type
  • The source and target fields are compatible.  For example, if the source field allows multiple selections, but the target does not, or the source allows selecting people and groups, but the target only allows selecting people
  • When the source field is a lookup to another list, the target field must use the same list
  • The source field is not read only
  • The source field is not a special field, such as ContentTypeId

After the field matches have been determined, a list item is created in the target list using a system update (does not trigger event receivers / workflows and the created by user is system).  In addition, when the field type is User, the user(s) are created in the target web if they don't already exist.

What Can Go Wrong

There are two common symptoms and the underlying causes of each is human error.  But don't beat yourself up; they are easy mistakes to make and correct.  Use the following to troubleshoot the issue:

  • When a SPD workflow doesn't copy one field to the target list:
    • The field names don't match
    • The field names match, but the field type and the settings do not 
  • In a document library, when none of the fields are copied (except the file name), or when all the fields are copied but intermittently:
    • The issue is that everything is working as designed and the workflow hasn't accounted for it!  There is a difference between New and Upload 

The Difference Between New and Upload in a Document Library

In a document library, users can add a document two ways through the browser.  The first option is to click New.  This opens the client application associated to the list template such as Microsoft Word.  In Word 2007, the list item properties appear on the Document Information Panel (In Word 2003, the list item properties are displayed in a dialog when you save the document):

Document Information Panel

Because the list item properties are captured by the client application, the document and properties are saved at the same time.  The save triggers the workflow created event receiver logic and the copy will succeed.  When the document is added using the Upload (or Upload Mutliple) option, the upload occurs in two stages.  The first stage is adding the file to the document library:

Upload Document Stage 1

The second stage is updating the list item properties.  At this point, the item has been added to the document library, the created event has fired, and the copy list item workflow has completed. The properties haven't been entered, so the workflow copied the document and blank property values to the target list.

Upload Document Stage 2

The following summarizes the differences between New and Upload:

  • When a document is uploaded using New, there is only a create 
  • When a document is uploaded using Upload, there is a create when the file is uploaded and an update when (and if) the properties are updated--but the properties are updated with a system update so the update event does not fire

Troubleshooting and Solutions

  • When only one field doesn't copy
    • Don't trust your eyes, copy the field name from the source list and paste it into the field name of the target list.  For example, how long does it take you to spot the difference between these two fields:  Source:Mutiline Field, Target:Multiline Field?
    • Compare the settings between the source field and target field.  Does one allow multiple values and the other does not?
  • In a document library when all fields don't copy or copy intermittently
    • The workflow needs to account for the difference between New and Upload
      • Configure the workflow to execute when the item is changed
      • Add a condition to the copy list item step to examine the workflow status

To overcome the issue with document libraries, one possible approach is to modify the SPD workflow as follows:

  • Set the workflow to execute only when the item is created
  • In the first step, add a wait activity to wait until a required field is not empty (a field that is entered in the "second  stage" after the document is uploaded)

Conclusion

SPD workflows are a business-user enabling technology and a useful tool in your SharePoint customization toolkit.  I hope this article sheds some light on how to implement a copy list item workflow using SPD and how to troubleshoot and resolve common issues with the approach.