Correlation tokens in Windows Workflow Foundation (WF)

You can consider a correlation token as a unique identifier that enables mapping between the objects in a workflow and the environment hosting the Windows Workflow Foundation (WF) workflow runtime.
 
Windows Workflow Foundation must provide some way for a workflow to communicate with other software. The Windows Workflow Foundation runtime acts as an intermediary for all communication with all workflows. When an incoming request arrives, the runtime receives it and then determines which workflow instance this request is destined for. The runtime then delivers the request to the target instance. In effect, the Windows Workflow Foundation acts as a proxy for all communication with software outside of the workflow.
 
You will have a separate correlation token for the each of the following:
The workflow itself
Each task you need to reference in the workflow
Important Note: 
Do not assign your workflow task the same correlation token as the workflow itself.
 
Declare the correlation token for the workflow in the OnWorkflowActivated activity. Then, for each activity that affects the entire workflow, bind that activity’s correlation token to the correlation token of the OnWorkflowActivated activity.

Workflow Development for Windows SharePoint Services

While Windows SharePoint Services 3.0 includes pre-built workflow templates, you can also create your own workflow templates. You can use either Visual Studio 2005 Designer for Windows Workflow Foundation, or a declarative rules-based, code-free workflow editor, such as Microsoft Office SharePoint Designer 2007. Because each authoring tool produces workflows with different attributes and capabilities, it is worth examining each tool in detail.

Using the Visual Studio 2005 Designer for Windows Workflow Foundation

In Visual Studio 2005, you can use the Visual Studio 2005 Designer for Windows Workflow Foundation to create workflow templates and custom workflow activities. You can include code in your workflow, as well as design forms to be used by the workflow to communicate with the workflow users during association and runtime. It is worth noting that when you are developing workflows templates in the Visual Studio 2005 Designer for Windows Workflow Foundation, you are not programming against a specific SharePoint site.
Using Office SharePoint Web Designer

By contrast, when you are creating a workflow in a declarative rules-based, code-free workflow editor, such as Office SharePoint Designer 2007, you are designing a workflow for the specific SharePoint site in which you are working. Office SharePoint Designer 2007 provides a user interface that enables you to create declarative rules-based workflows for the selected site. With Office SharePoint Designer 2007, you are in effect assembling pre-existing activities into workflows.

You cannot create your own activities in Office SharePoint Designer 2007; nor can you write code-beside files. Using Office SharePoint Designer 2007, you create and deploy XML-based markup files, rather than an assembly that contains code.

Comparing Workflow Development Processes

The figure below illustrates the various steps that need to be performed to create, deploy, associate, and run a workflow using each of the authoring tools. In general, the largest difference between the two tools is this:

Workflow authoring in the Visual Studio 2005 Designer for Windows Workflow Foundation is performed by a professional developer, who is creating a workflow template that can be deployed across multiple sites, and contains custom code and activities. The developer then turns the workflow template over to a server administrator for actual deployment and association.

Workflow authoring in Office SharePoint Designer 2007 is likely done by someone other than a professional developer, such as a web designer or knowledge worker, who wants to create a workflow for a specific list or document library. In this case, the designer is limited to the workflow activities on their ‘safe list’, and the workflow cannot include custom code. The workflow author deploys the workflow template directly to the list or document library as part of the workflow authoring process.

Although the steps in the workflow creation process are specified by role and application, obviously the same person can perform more than one function, based on your business processes. For example, the same person might develop the workflow in Visual Studio 2005 and install it on the server using Windows SharePoint Services 3.0.

Windows Workflow Foundation Correlation tokens

 

You can consider a correlation token as a unique identifier that enables mapping between the objects in a workflow and the environment hosting the Windows Workflow Foundation (WF) workflow runtime.
Windows Workflow Foundation must provide some way for a workflow to communicate with other software. The Windows Workflow Foundation runtime acts as an intermediary for all communication with all workflows.
When an incoming request arrives, the runtime receives it and then determines which workflow instance this request is destined for.
The runtime then delivers the request to the target instance. In effect, the Windows Workflow Foundation acts as a proxy for all communication with software outside of the workflow.
You will have a separate correlation token for the each of the following:
  • The workflow itself
  • Each task you need to reference in the workflow
Important Note:
Do not assign your workflow task the same correlation token as the workflow itself.
Declare the correlation token for the workflow in the OnWorkflowActivated activity. Then, for each activity that affects the entire workflow, bind that activity’s correlation token to the correlation token of the OnWorkflowActivated activity.