Create Custom Workflow Action using Visual Studio

The out of the box actions for SharePoint Workflow provided in SharePoint Designer are really great and help us almost to do what we want to complete the business needs, but sometimes we need more to fulfill the business requirements.

Visual studio 2010 helps us to create a custom Workflow Actions. In this walkthrough we will take you step by step to create a custom action that will create a new SharePoint site.

Hot Post(s) Now
Free SharePoint 2010 Web Parts
SharePoint HR

Create Workflow Activity

  1. Open Visual Studio 2010 and create an Empty SharePoint Project from the SharePoint 2010 template; name it CreateSiteWF
  2. In SharePoint Customization Wizard, provide the SharePoint Server URL and select “Deploy as a Farm Solution” and click Finish
  3. Right click the References folder and select Add Reference to add the following:
    1. Microsoft.SharePoint.dll
    2. Microsoft.Office.Workflow.Actions.dll
    3. System.Workflow.ComponentModel.dll
  4. Right click the project name in the solution explorer and select add new item
  5. Click the common item then select Class; name it “CreateSite.cs” and press add
  6. Replace the class code with the code available in the Downloads area below

Deploy the Workflow Activity

Before you can deploy the activity to SharePoint server we need to do some preparations:

  1. Right click the project name in solution explorer and select Add then SharePoint Mapped Folder
  2. In the SharePoint Mapped folder dialog, expand the “Template” folder then expand again the “1033” folder then select the “Workflow” folder and press OK
  3. Now right click the newly added mapped folder and click Add New Item
  4. In the Add new Item dialog, select the Data node then select “XML File”
  5. Name it “SPCustomActivities.actions” and press Add
  6. Replace it is content with the content available in xml file in the Downloads area below
  7. Right click the Feature folder and select Add Feature
  8. Rename the new Feature file and its Title to CreateSiteWFFeature.
  9. For the feature scope, change it to Farm
  10. Right click the feature and select add Event Receiver
  11. Replace it is content with the content available in Event Receiver file in the Downloads area below

Now we are ready to build and deploy the solution.

After deploying the solution, you can now go to the SharePoint Designer, open or create a new workflow and in the Action list you should see “CreateSite”

(Click the image to enlarge)

Custom Workflow Activity

Download Workflow Activity Files

Name

Downloads

Create Site Class Download
Feature Event Receiver Download
SPCustomActivities.actions Download

Hot Post(s) Now
Free SharePoint 2010 Web Parts
SharePoint HR

7 Thoughts on “Create Custom Workflow Action using Visual Studio

  1. electronic Workflow Source on March 28, 2012 at 11:48 pm said:

    Thanks , I have recently been looking for info approximately this subject
    for ages and yours is the greatest I have discovered so far.
    However, what concerning the conclusion? Are you certain in regards to
    the source?

  2. ARG on May 1, 2012 at 9:13 am said:

    Thanks a lot . I use this. But when i deploy VS and open SPD , I don’t find custom work flow in it !

  3. This is exactly what I have been looking for. But, could you repost the files? The links do not seem to be working.

    • You can right click the file link and save it to you computer

      • Yes, I understand. Here is what I get when I attempt to download the files:

        404 Not FoundNot FoundThe requested URL “/eng/downloads/CreateSite.txt” was not found on this server.

        Was hoping you could re-post the files. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>