Thursday, August 30, 2012

Migrating Workflow Items

​When performing SharePoint migrations, you will inevitably come across lists with associated workflows needing migration.  These can be challenging to migrate – especially if you just looking to migrate the data, and not the associated workflow(s).  Metalogix has a nice write up of how to use their tool to copy workflows (http://www.metalogix.com/help/Migration-Manager-for-SharePoint/SharePoint-Edition/002_HowTo/003_MigrationActions/017_CopyWorkflows.htm), but this article doesn’t help if all you want is the data from a list.  The Migration Manager will not allow you to copy items from a list which are associated with a workflow, unless the workflow and associated content types are migrated as well.I recently ran into this situation during a migration.  We had a list of tasks that were being created by a workflow in our legacy system.  The target system was setup as a clean environment, and while it had the workflow in place, they weren’t setup identically as the source.  The Migration Manager software refused to migrate the tasks unless we migrated the workflow as well.  Our simplest solution was to break the workflow association on the source server, then use the Migration Manager to migrate the list items to the target server.Here’s how we did it: 
  • We created a .NET console application (our “MigrationHelper”) to read the source list, grab each field we cared about (including all metadata) and write the data to a temporary list on the same server.  This temporary list could be created/re-created over and over with no ill effects.  It contained all of the data that we needed, but not the associated workflow.
  • We used the Migration Manager to migrate the temporary items to the destination list.  Since the list definitions were different, we simply mapped fields from the source to the destination using the built-in mapping functionality of the Migration Manager tool.
  • We created an incremental job to migrate changed data in the temporary source list to the destination list.  We had a large number of items in the list and wanted our “go-live” night to require the least amount of data transfer possible.  (I’ll write a future blog entry on how and why you should do this)

The end result was a process that required a small amount of code on our part (reading the source list, deleting/creating the temporary list, copying data to the temporary list) and left the bulk of the migration to the Migration Manager.  Focusing on the limitations of the tool allowed us to work quickly and efficiently.  Yes, we had to write some custom code, but we didn’t have to reinvent the wheel and write code that Metalogix had already written (see my previous blog entry on using the right tool for the job:http://www.timlinenterprises.com/consultingknowhow/Lists/Posts/Post.aspx?ID=5).Have you ever run into a similar problem?  What did you do to solve it?

No comments: