How to create sequential workflow in SharePoint 2010 using Visual Studio 2010

Steps Involved:

  1. Open Visual Studio 2010 by going Start | All Programs | Microsoft Visual Studio 2010 | Right click on Microsoft Visual Studio 2010 and click on Run as administrator.
  2. Go to File tab, click on New and then click on Project.
  3. In the New Project dialog box, expand the SharePoint node, and then select the 2010 node.
  4. In the Templates pane, select Sequential Workflow.
  5.  Enter the Name as SequentialWorkflow and then click OK.
  6. Enter the local site that you want to use it for debugging.
  7. Select “Deploy as a farm solution” and then click on Next.
  8. Leave the name of the workflow as SequentialWorkflow-Workflow1 and select the List Workflow.

 wfName.png

  1. Click on Next.
  2. Select the list or library to associate your workflow.

 selectlist.png

  1. Specify the conditions for how your workflow should be started.

 wfStart.png

  1. Click on Finish.
Workflow.cs:

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;

namespace SequentialWorkflow.Workflow1
{
    public sealed partial class Workflow1 : SequentialWorkflowActivity
    {
        public Workflow1()
        {
            InitializeComponent();
        }

        public Guid workflowId = default(System.Guid);
        public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();

        private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
        {

        }
    }
}
 



onWorkflowActivated1 properties: 

wfproperties.png 


Right click the solution and click on Deploy. Open SharePoint Site and go to Testing custom list to which the workflow is associated by default.Create a new item and you could be able to see a new column named SequentialWorkflow – Workflow1 which show the status of the workflow.


output.png

 


Note:

In this project I have not added any activity so the workflow status will show completed. This blog is just to explain how to create sequential workflow using Visual Studio 2010 which will be used in my next blog where you will see how to use CreateTask activity.