Archive for July 8, 2011

Move a Sharepoint Designer Workflow to a different Farm

Sharepoint 2010 has introduced lots of new features in Sharepoint Designer Workflows. What used to be a technology designed to allow some power users to create their own workflows and associate them with Sharepoint lists is now a much more powerful tool. Amongst the new features introduced are the possibility of creating reusable and global reusable workflow that can be reused in the same site or at the Site collection level, create Site level workflows and also to export Sharepoint Designer workflows to .WSP templates

What we are interested here is in this very last new feature. In theory, Sharepoint Designer workflows can be exported to solution files and then imported in a different Site Collection or a different Sharepoint Farm. Now they can even be opened in Visual Studio 2010, although it’s not a reversible process and once opened in Visual Studio they can’t be changed using Sharepoint Designer anymore. In previous versions it was a very bad idea for developers to create workflows in Sharepoint Designer, the main issue being that these workflows could not be moved across environments. It was not possible to design a workflow in a development platform, then move it to a test environment for testing and finally once accepted deploy it to production, workflows had to be created directly at production and tested from there.

Sharepoint Designer workflows weren’t meant to be used by developers to create new workflows. And they still aren’t. What I try to show in this article is how to move Sharepoint Designer 2010 workflows across farms and while this feature can be useful in many scenarios, I strongly encourage you as a developer to try to build your workflows in Visual Studio, this is the proper way to implement, distribute and mantain any workflow. 
So let’s ignore that last warning and try to move the workflow 🙂

What we have to do here is create a new Sharepoint Designer workflow, it has to be a reusable workflow because only those can be then saved as templates. For this demo I just created a workflow that logged a string in the workflow history. Once we have finished with the workflow we save it and we click on the “Save as Template” button on the ribbon bar.

This will generate our Solution .wsp file and save it in the “Site Assets” document library on the current site.

After this the next step is to download a copy of the Solution file and upload it to the other Sharepoint Farm where we want to move the workflow to. We navigate to the Solutions gallery and upload the .wsp file, finally we have to activate the solution.

Once activated, a new feature will appear on the Site Features of all sites in the current Site Collection, we navigate to the Site where we want to use the new workflow and activate that feature.

This feature deploys the workflow to the workflows list and after activating it we would expect to have the new workflow available in the Site Collection. Unfortunately, if we navigate to the Workflows list at the Site Settings page, we won’t find our workflow there ! 
I opened the feature definition file that was deployed as part of the solution and I found that it should have deployed the workflow .xoml file in the workflows gallery of the Site Collection. To check if that was the case, I opened Sharepoint Designer and navigated to the Workflows section and surprise! the new workflow was there.

What we need to do then is open the workflow in Sharepoint Designer and click on the Publish button. This will publish the workflow again in the Site Collection and after we do that it will appear on the workflows list and we will be able to run it and associate it to Sharepoint Lists.