Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

SharePoint Workflow Wizard in Visual Studio 2008

3.38/5 (10 votes)
16 May 2008CPOL3 min read 1  
SharePoint Workflows Wizard in Visual Studio 2008

Introduction

Visual Studio tools for office 2008 provides variety of workflow templates. Ofcourse, these workflow templates are based on Windows Workflow foundation (WF) . Continuing the efforts of integrating the other technologies usage and making the Visual Studio as a single UI IDE for developing various components of different technology, Microsoft have came up with few workflow templates specific for SharePoint in Visual Studio tools for office. This article will give you sneak preview about the sharepoint workflows and also provide details on why should we use the sharepoint workflow templates of Visual studio 2008. Visual Studio 2008 provides lot of workflow templates. If you see the screen , two of those belong to SharePoint.

1. SharePoint 2007 Sequential workflow
2. SharePoint 2007 State Machine workflow

Brief Overview

Sequential workflow represents a workflow as a sequence of steps that must be executed in order until the last activity is completed. A state machine workflow represents a set of states,transitions, and actions. One state is denoted as the start state, and then, based on an event, a transition can be made to another state. On the right side is a typical example of a Sequential workflow. When you select any of these workflow templates, it executes the workflow wizard that allows debugging on the workflows on SharePoint that requires special permissions. For e.g. this wizard takes care of deploying workflow customization on Global Assembly Cache (GAC).

2.JPG<path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"><lock aspectratio="t" v:ext="edit"><shape id="Picture_x0020_1" style="VISIBILITY: visible; WIDTH: 209.25pt; HEIGHT: 185.25pt" alt="Bb386211_SP_Sequential(en-us,VS_90).png" type="#_x0000_t75" o:spid="_x0000_i1025"><imagedata o:title="Bb386211_SP_Sequential(en-us,VS_90)" src="file:///C:\DOCUME~1\nishithp\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.png">

Step 1. Select the workflow and the site for debugging

As soon as you select any of the workflow templates, (for this article, I am assuming that you selected the SharePoint 2007 Sequential Workflow), it presents a simple Wizard during project creation to capture settings in an easy-to-use Wizard. In the first step, it asks you to give the workflow a name and also choose a valid SharePoint site where the workflow will be deployed and debugged. One thing would be a restriction on this site selection is that this site should be a local site and cannot be a remote SharePoint site. I hope this issues gets resolved in upcoming SP1 version of VS 2008 . Click on "Next" to move to next step.

3.JPG<path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"><lock aspectratio="t" v:ext="edit"><shape id="Picture_x0020_10" style="VISIBILITY: visible; WIDTH: 229.5pt; HEIGHT: 183pt" type="#_x0000_t75" o:spid="_x0000_i1028"><imagedata src="file:///C:\DOCUME~1\nishithp\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.png">

Step 2 : Choosing the library or list

Since you have selected the SharePoint site on the first step, this time you need to associate the workflow template with a document library or list. Before the VSTO 2008, this work has to be outside by going in the IDE of SharePoint. In this , you choose the document library or the lists. One thing to be aware is that, this wizard does not allow you to create new lists or library. This work has to be still done either manually by going to SharePoint or by using SharePoint object Model. Click on "Next" to move to next step.

4.JPG<shape id="Picture_x0020_13" style="VISIBILITY: visible; WIDTH: 228.75pt; HEIGHT: 182.25pt" type="#_x0000_t75" o:spid="_x0000_i1027"><imagedata src="file:///C:\DOCUME~1\nishithp\LOCALS~1\Temp\msohtmlclip1\01\clip_image003.png">

Step3. : Invoking a workflow

On the last step, wizard lets you configure how an instance of your workflow can be started. There are three ways as shown on the screen

1. Manually by users

2. When an item is created

3. When an item is changed

The first two are selected by default for the easy. After setting these simple configurations in place, the wizard completes, and VSTO creates the new project.

5.JPG<shape id="Picture_x0020_16" style="VISIBILITY: visible; WIDTH: 229.5pt; HEIGHT: 182.25pt" type="#_x0000_t75" o:spid="_x0000_i1026"><imagedata src="file:///C:\DOCUME~1\nishithp\LOCALS~1\Temp\msohtmlclip1\01\clip_image005.png">

Project created : Lets play now

After setting this, a project gets created and by default , few files like features.xml, workflow.xml etc gets created. Now you if you are an expert on workflow foundation, This is your time to do something with the workflow based on your business requirement. Once done, deployment is also as easy as pressing F5. Once deployment, workflow can be debugged by well within the Visual Studio IDE

6.JPG<shape id="Picture_x0020_25" style="VISIBILITY: visible; WIDTH: 228pt; HEIGHT: 165.75pt" type="#_x0000_t75" o:spid="_x0000_i1025"><imagedata src="file:///C:\DOCUME~1\nishithp\LOCALS~1\Temp\msohtmlclip1\01\clip_image007.png">

Conclusion

Earlier debugging the workflow developed in WF and deployed in SharePoint requires a lot of manual steps to be done. These SharePoint workflow templates have brought a sigh of relief for all those developers. This simple wizard has really avoided lot of manual process. I am sure there are much more you will find in Visual studio 2008.

Happy Coding

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)