Create reusable site workflow in SharePoint Designer

Workflow development within SharePoint 2010 has become a lot better, I even worked with SharePoint Designer :D .
One off the things I particullary like is the ability to export your SPD created workflows and afterwards import it into Visual Studio, this developers to have the workflows created by someone else. And after the workflows are created the can be send to the developer(s) and used within the provisioning.
But unfortunatly you can not you are not able to export your site workflow in SPD because the icon is disabled.

Disabled save as template

Disabled save as template

After some research I’ve found a way to have an exported workflow to be imported into Visual Studio and used in the provisioning.
Just start creating your workflow as a reusable workflow within SharePoint Designer, after you’ve added all your actions and conditions you can use the Save as Template button to save your workflow into the Assets library in your site collection.
Create a new “Import reusable workflow” project in your Visual Studio.

Import reusable workflow project

Import reusable workflow project

After you have fully imported your workflow, click the icon to Show All Files Show all files in the solution exporer. You’ll now see all hidden files withi the solution explorer, now double click the SharePointProjectItem.spdata file. The file will look something like this.

<ProjectItem Type="Microsoft.VisualStudio.SharePoint.Workflow" DefaultFile="ReusableWF.xoml" SupportedTrustLevels="FullTrust" SupportedDeploymentScopes="Site" xmlns="http://schemas.microsoft.com/VisualStudio/2010/SharePointTools/SharePointProjectItemModel">
  <Files>
    <ProjectItemFile Source="Elements.xml" Target="ReusableWFFT" Type="ElementManifest" />
  </Files>
</ProjectItem>

After experimenting a bit with Visual Studio and the Site Workflow, I found the difference between the reusable workflow and the site workflow.
The difference was the follow piece of Xml.

  <ExtensionData>
    <ExtensionDataItem Key="WorkflowType" Value="Site" />
  </ExtensionData>

The ExtensionData element was present behind the element. After adding the ExtensionData element your Xml should look something like this.

<ProjectItem Type="Microsoft.VisualStudio.SharePoint.Workflow" DefaultFile="ReusableWF.xoml" SupportedTrustLevels="FullTrust" SupportedDeploymentScopes="Site" xmlns="http://schemas.microsoft.com/VisualStudio/2010/SharePointTools/SharePointProjectItemModel">
  <Files>
    <ProjectItemFile Source="Elements.xml" Target="ReusableWFFT" Type="ElementManifest" />
  </Files>
  <ExtensionData>
    <ExtensionDataItem Key="WorkflowType" Value="Site" />
  </ExtensionData>
</ProjectItem>

If you now save your file, then close your solution and afterwards reopen it again your workflow is now deployable as site workflow.
To check if this “hack” worked you should open the “Package Explorer” (“View” > “Other Windows” > “Package Explorer”), select your workflow within the Package Explorer and look at your Properties window. The last property is “Workflow Type”, it should say “Site”.

Workflow Type: Site

Workflow Type: Site

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

WordPress Themes