Share via


Correlation Tokens in Workflows

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

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

    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.

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 Windows SharePoint Services Overview

Workflow Initiation in Windows SharePoint Services

How Windows SharePoint Services Processes Workflow Activities