Share via


SharePoint 2007 Workflow Solutions

Visual Studio provides tools to help you create custom workflows that manage the life cycle of documents and list items in a SharePoint web site. The tools include a designer, a complete set of drag-and-drop activity controls, and the necessary assembly references. Visual Studio also includes the SharePoint Customization Wizard, which significantly reduces the configuration steps that are required to debug the workflow in Visual Studio.

Note

To use the SharePoint 2007 workflow project templates, you must install all of the prerequisites for SharePoint 2007 projects as outlined in Requirements for Developing SharePoint Solutions. In addition, the templates work only with .NET Framework 3.5 or earlier versions of .NET Framework.

Microsoft Office SharePoint Server 2007 contains several built-in workflow templates. For example, if you want a new document to pass through a basic approval process, you can use the built-in Approval workflow template. You can also create custom workflow templates to manage advanced document processes.

For more information about SharePoint, see Windows SharePoint Services Overview and Microsoft Office SharePoint 2007 Server Product Overview.

Workflows in SharePoint

When you add a workflow to a SharePoint library or list, you enforce a business process on all items in the library or list. A workflow describes the actions that the system or users must perform on each item, such as sending the item to be edited and then reviewed. These actions, called activities, are the building blocks of the workflow.

After you add a SharePoint workflow, you deploy it to a SharePoint web site and associate the workflow with a library or list. Users can start a workflow instance to process items in the library, or list. For more information, see Using workflows to manage processes.

Creating Custom SharePoint Workflows

Create SharePoint workflows by using either the SharePoint 2007 Sequential Workflow or the SharePoint 2007 State Machine Workflow project template.

A sequential workflow represents a workflow as a procession of steps that must be executed in order until the last activity is completed. The following illustration shows an example of a sequential workflow.

Sequential workflow

Sequential Workflow

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. The following diagram shows an example of a state machine workflow.

State machine workflow

State Machine Workflow

For more information about workflow types, see Workflow Types.

Using the Wizard

When you create a SharePoint workflow project, you start by specifying its settings in the SharePoint Customization Wizard. The wizard stores these settings and creates a project in Solution Explorer. This project contains a code file, several files that are used to deploy the workflow template, and references to assemblies that you must have to create a custom SharePoint workflow template.

For step-by-step information, see How to: Create a SharePoint Workflow Project.

Designing a SharePoint Workflow

After you define all of the steps in your business process, use the Workflow Designer in Visual Studio to design a SharePoint workflow. After you create a workflow project, the workflow opens in the designer. To open the designer again at any time, double-click either Workflow1.cs or Workflow1.vb in Solution Explorer.

Activities

To design a workflow, add activities from the Toolbox to a workflow schedule on the designer. A workflow schedule contains the sequence of activities in the order that they should be performed.

There are two types of activities:

  • Simple activities perform a single unit of work, such as "delay for 1 day" or "start Web service."

  • Composite activities contain other activities; for example, a conditional activity might contain two branches.

Both types of activities are available in the Toolbox.

Activities can have properties, methods, and events. Use the Properties window to set the properties of an activity.

You can also create a custom activity. For more information, see Create a Custom Activity.

Activities are organized in the following tabs in the Toolbox:

  • Windows Workflow v3.0

  • Windows Workflow v3.5

  • SharePoint Workflow

Windows Workflow Activities

The Windows Workflow tabs contain activities that are provided by the Windows Workflow Foundation. You can use these activities to create workflow schedules for any kind of Windows workflow application.

For more information about the activities listed in the Windows Workflow tabs, see Windows Workflow Foundation Activities. For more information about the Windows Workflow Foundation, see Windows Workflow Foundation Overview.

SharePoint Workflow Activities

The SharePoint Workflow tab contains specialized activities for Windows SharePoint Services 3.0 and SharePoint Server 2007. These activities simplify and streamline the development of document life cycle workflows. For more information about the activities listed in the SharePoint Workflow tab, see Workflow Activities for Windows SharePoint Services Overview.

Working with Activities in the Designer

Your workflow schedule can contain a combination of Windows Workflow activities and SharePoint Workflow activities.

The designer displays visual cues to help you position and configure activities correctly. When you drag an activity onto the workflow schedule, the designer displays green plus-sign (+) icons that show you valid locations for that activity in the workflow. You cannot position an activity in a location where it would not be valid. For example, you cannot position a Send activity as the first activity in a Listen activity branch. For more information about how to use the designer, see Visual Studio 2005 Designer for Windows Workflow Foundation Overview.

Collecting Information During the Workflow

You might want to gather information from users at predefined times in the workflow. You can collect information by using forms or item properties.

Forms

Forms are similar to dialog boxes that contain questions and provide ways for users to give answers.

There are four types of forms that you can create for a workflow:

  • Association

  • Initiation

  • Modification

  • Task

For example, you could design a form that collects feedback from document reviewers. Users must provide feedback before the workflow can continue. This type of a form is called a task form.

Note

Visual Studio provides templates for association and initiation forms. For more information, see Walkthrough: Creating a Workflow with Association and Initiation Forms.

Item Properties

You can also collect information from users by using the properties of an item in the SharePoint library or list. The main code file (Workflow1.cs or Workflow1.vb) declares an instance of the Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties.WorkflowProperties class named workflowProperties. Use the workflowProperties object to access the properties of the library or list in code. For an example, see Walkthrough: Creating and Debugging a SharePoint Workflow Solution.

Debugging a SharePoint Workflow Template

You can debug a SharePoint workflow project just as you would debug other Visual Studio projects. When you start the Visual Studio debugger, Visual Studio uses the settings that you specify in the SharePoint Customization Wizard to open the appropriate SharePoint web site and automatically associate the workflow template with the appropriate library or list. Visual Studio also attaches the Visual Studio debugger to the SharePoint Services 3.0 process named w3wp.exe.

To test the workflow, you must start it manually. For more information, see Debugging SharePoint Workflow Solutions.

Deploying a SharePoint Workflow Template

After you create a workflow in Visual Studio, you deploy it the same as any other SharePoint project. When you press F5, the workflow is packaged and deployed to SharePoint. For more information, see Deploying SharePoint Solutions.

See Also

Other Resources

Creating SharePoint Workflow Solutions

Developer Introduction to Workflows for Windows SharePoint Services 3.0 and SharePoint Server 2007

Windows Workflow Foundation Overview

Windows Workflow Foundation Programming Guide

Visual Studio 2005 Designer for Windows Workflow Foundation Overview

Windows Workflow Foundation Activities

Workflow Activities for Windows SharePoint Services Overview

Workflow Object Model in Windows SharePoint Services Overview

Welcome to the Microsoft Office SharePoint Server 2007 SDK

InfoPath Forms for Workflows

Workflow Forms Overview

Workflow Deployment Using Features