Import a SharePoint Designer Reusable Workflow into Visual Studio

Everyone googling for Import SharePoint Designer Reusable Workflow into Visual Studio has definitely covered this msdn article. I also have followed the article thoroughly for one my project task this week and found there is something missing at the last step of the article. Do you know what it is? Let me tell you the answer later on =)

So, let’s go start the implementation …


1. Site Column “Expiration” as Date Time field
2. Site Content Type “MyContentType” as Custom List content type
3. Custom List “MyList” based on “MyContentType”


Step 1: Create Reusable Workflow in SharePoint Designer

I don’t want to go to much detail about this step, cause I found an excellent technet video from Asif Rehmani about creating reusable workflow in SharePoint Designer. Follow that video and you should be good. My reusable workflow looks like below.
And after I publish it, I could see the workflow is available on MyContentType. Not in This List, Item or Folder content type.


Step 2: Save Reusable Workflow as Template


In this step, we’re going to Save it As Template and it would be available as WSP file in Site Asset Library. Download the WSP file to your local folder. Note: Do NOT Publish Globally, since you WILL NOT be able to Save As Template afterwards.


Step 3: Import the WSP file into Visual Studio

1. In Visual Studio, on the menu bar, choose File > New > Project.

2. In the New Project dialog box, expand the SharePoint node under either Visual C# and then choose the 2010 node.

3. In the Templates pane, choose the Import Reusable SharePoint 2010 Workflow template, leave the name of the project as MyWorkflowImportProject, and then choose the OK button. The SharePoint Customization Wizard appears.

4. On the Specify the site and security level for debugging page, enter the URL for the second SharePoint site: http://<site url>/.

5. In the What is the trust level for this SharePoint solution? section, choose the Deploy as a farm solution option button, and then choose the Next button.

6. In the Specify the new project source page, browse to the location on the system where you previously saved the .wsp file, open the file, and then choose the Next button. Then, Choose the Finish button to import all available items in the .wsp file. This displays a list of reusable workflows available for importing.

7. In the Select items to import box, choose the SPD Task Workflow workflow, and then choose the Finish button.

After the import operation is finished, a project named MyWorkflowImportProject is created containing a workflow named MyReusableWorkflowFT. In this folder is the workflow’s definition file Elements.xml and the workflow designer file (.xoml). The designer contains two files: the rules file (.rules) and the code-behind .cs file.

8. In Solution Explorer, Delete the Other Imported Files folder.

9. In the Elements.xml file, Delete InstantiationURL=”_layouts/IniErkflIP.sspx” and Update Name=”My Reusable Workflow”.

10. Ensure MyReusableWorkflowFT module included in your Feature, Update Feature Title and Scope to Site.

11. Build and Deploy the solution. Do NOT forget to delete your SharePoint Designer Publishing Workflow that you created on step 1 so you dont get mix up.


Step 4: Associate the Workflow

So, I go to MyList Settings > Workflow Settings > Add a Workflow to associate My Reusable Workflow to the list. Then, I found the issue …



The Problem and Missing Piece

I do NOT want this and I want My Reusable Workflow to be available on MyContentType only. After googling for sometime, I still can not find any clues … So, I have a look and follow on the msdn article again. Then, I started to see there is AssociationCategories element in Elements.xml under  MyReusableWorkflowFT. This is the Ahha moment …

Based on msdn article, the missing piece is to specify the AssociationCategories value whether it is General, List or ContentType. I found Mano Mangaldas blog that provide more example on AssociationCategories value variations.

My updated Elements.xml would look like below:








Tagged: , , , , , , , , , , , ,

2 thoughts on “Import a SharePoint Designer Reusable Workflow into Visual Studio

  1. dineshramitc 08/07/2014 at 3:49 PM Reply

    Reblogged this on Dinesh Ram Kali..

  2. […] my previous article to set Expiry column using Reusable Workflow, I would also like to Configure Information Management Policy at Content type programmatically on […]

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: