SharePoint Sequential Workflow Sample

This sample demonstrates how to create a basic sequential workflow template. The workflow adds a new task to the SharePoint Tasks list when you add a document to a document library in SharePoint. When you edit the task, the workflow checks a property of the task to determine whether the task is complete. If the task has been completed, the workflow finishes.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To run this sample

  1. Press F5.

    The Documents page of the default SharePoint site opens.

  2. In the Documents page, click New to create a new document.

  3. Save the document to the default location.

    This adds the document to the Documents list and starts the workflow.

  4. Close the document.

  5. Return to the Documents page of the default SharePoint Web site.

  6. In the Documents page, verify that the value underneath the Microsoft.Samples.Vsto.SeqWkFlow column is set to In Progress, which is the current status of the workflow.

  7. In the Site Hierarchy pane, click Tasks.

    The Task page appears.

  8. In the Tasks page, point to the SharePoint Workflow Task, click the down arrow, and then click Edit Item.

  9. Set % Complete to 100 and then click OK.

  10. Return to the Documents page of the default SharePoint Web site.

    In the Documents page, verify that the value underneath the Microsoft.Samples.Vsto.SeqWkFlow column is set to Completed. This indicates that workflow is finished and that the task associated with the document has been completed.

Requirements

This sample requires the following applications:

  • Visual Studio Tools for Office (an optional component of Visual Studio 2008 Professional and Visual Studio Team System).

  • Windows Server 2003 or Windows Server 2008.

  • Microsoft Office SharePoint Server 2007.

  • Microsoft Office Word 2007 or Microsoft Office Word 2003.

Demonstrates

This sample demonstrates the following concepts:

  • Using the Visual Studio Tools for Office SharePoint 2007 Sequential Workflow template.

  • Specifying the following debug configuration settings:

    • SharePoint site.

    • Document library with which the workflow should be automatically associated.

    • Start conditions.

    • History and task lists to use.

  • Creating a workflow schedule by using the Designer for Windows Workflow Foundation.

  • Adding the following activities to the workflow schedule:

    • CreateTask

      This activity creates a new task in SharePoint and sets the initial properties that appear for the task.

    • OnTaskChanged

      This activity invokes custom code when the task is edited in SharePoint. If the user sets the PercentComplete property to 100, this code sets a field to indicate that the task is complete.

    • WhileActivity

      The WhileActivity activity checks the value of the field that is set by the OnTaskChanged activity to determine whether to complete the workflow.

See Also

Tasks

Walkthrough: Creating and Debugging a SharePoint Workflow Solution

How to: Create a SharePoint Workflow Project

Concepts

SharePoint Workflow Solutions

Debugging SharePoint Workflow Solutions

Other Resources

Samples and Walkthroughs (Office Development)