The basics of custom Visual Studio workflows for SharePoint
Learn what the basic concepts and terms are of custom workflows that are created through Visual Studio using Windows Workflow Foundation and which can be used on lists, libraries, and content types in SharePoint.
Two types of workflows
You can create two types of workflows in Visual Studio:
- State Machine
A sequential workflow consists of a set of activities, which are executed in a rigid, predefined manner. The work performed generally follows a predictable number of pathways.
A good example of the application of a sequential workflow is a document approval process, where a document is modified and reviewed by many people. The document would go from person to person, and thus follow a route where the logic has been predefined.
State Machine workflows
A state machine workflow consists of states and transitions between states, which can be executed randomly. The work performed generally follows unpredictable pathways.
A good example of the application of a state machine workflow is a defect tracking system. While a defect can be marked as fixed by a developer, a tester can change the status of the defect back to active if he finds that the defect has not been resolved. The defect can go from state to state several times or end up with a state such as refer to customer or functions as designed. The amount of possible states a defect can go through are unlimited and cannot be defined beforehand.
The difference between a workflow template and a workflow
A workflow template is the blueprint for a workflow; it defines the sequence of events, actions, or activities that take place when the workflow does its work.
A workflow template can be associated with a list, library, or content type. Associating is the act of binding a workflow template to a SharePoint object. Once you associate a workflow template with a list, library, or content type, it becomes a workflow, that is, a piece of work that can be run on the object.
When you start the workflow, an instance of the workflow is created to run on the object. The latter is called a workflow instance.
Identifying relationships through correlation tokens
A workflow instance interacts with several SharePoint objects (task lists, and documents or items) during its lifetime. In SharePoint you can have many workflow instances running at the same time and interacting with several objects at the same time.
To be able to identify which workflow instance is interacting with which object, you must use an identifier that links one particular workflow instance to one particular SharePoint object. Each workflow instance must be bound to its own items.
Such an identifier is called a correlation token. A correlation token links a workflow instance to its documents, items, and tasks. It prevents confusion between different workflow instances.
- Visual Studio workflow: Copy a document from one SharePoint document library to another
- 3 Ways to create workflows for WSS 3.0 and Office SharePoint 2007
- How to create custom Visual Studio 2005 workflows for WSS 3 or Office SharePoint Server 2007