How to create sequential workflow in SharePoint 2010 using Visual Studio 2010
In this blog you will see how to create a sequential workflow in SharePoint 2010 using Visual Studio 2010.
Steps Involved:
- 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.
- Go to File
tab, click on New and then click on Project.
- In the New
Project dialog box,
expand the SharePoint node, and then select the 2010 node.
- In the Templates
pane, select Sequential Workflow.
- Enter the Name as SequentialWorkflow and then click OK.
- Enter the local
site that you want to use it for debugging.
- Select “Deploy
as a farm solution” and then click on Next.
- Leave the name
of the workflow as SequentialWorkflow-Workflow1 and select the List
Workflow.
- Click on Next.
- Select the list or
library to associate your workflow.
- Specify the conditions
for how your workflow should be started.
- 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:
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.
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.