Correlation Tokens in Workflows

Applies to: SharePoint Foundation 2010

You can consider a correlation token as a unique identifier that enables mapping between the objects in a workflow and the environment that is 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

    Note

    Do not assign to your workflow task the same correlation token assigned to 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.

Each specific task within the workflow should have its own correlation token, which each related activity can use to access the same, task-specific information. For example, if in your workflow you want to reference the same task in CreateTask, CompleteTask, and OnTaskChanged activities, you would bind the CorrelationToken property of each of these activities to the same correlation token variable.

See Also

Concepts

Workflow Activities for SharePoint Foundation

Workflow Initiation in SharePoint Foundation

How SharePoint Foundation Processes Workflow Activities