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 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. |
Press F5.
The Documents page of the default SharePoint site opens.
In the Documents page, click New to create a new document.
Save the document to the default location.
This adds the document to the Documents list and starts the workflow.
Close the document.
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 In Progress, which is the current status of the workflow.
In the Site Hierarchy pane, click Tasks.
The Task page appears.
In the Tasks page, point to the SharePoint Workflow Task, click the down arrow, and then click Edit Item.
Set % Complete to 100 and then click OK.
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.
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.
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:
-
This activity creates a new task in SharePoint and sets the initial properties that appear for the task.
-
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.
-
The WhileActivity activity checks the value of the field that is set by the OnTaskChanged activity to determine whether to complete the workflow.
-
Walkthrough: Creating and Debugging a SharePoint Workflow Solution
How to: Create a SharePoint Workflow Project