Activity onWorkflowItemChanged validation warning: The correlation token may be uninitialized

Sun, Sep 23, 2012 2-minute read

Update: the below information is useful reference, but you may find it leads to undesirable results, where your workflowItem events fire repeatedly. Read the below, and then read this.

Working in Visual Studio 2010 and designing SharePoint 2010 state machine and sequential workflows, you may come across the following warning message when building and deploying your solution when using the onWorkflowItemChanged event:

Activity ‘onWorkflowItemChanged’ validation warning: The correlation token may be uninitialized

You will also probably notice that your workflow doesn’t respond or wake up to any onWorkflowItemChanged events. This is almost certainly due to the correlation token you’re using. The way to get this working correctly is:

  1. Add (or check) the onWorkflowActivated event (which should be the first event in your workflow), ensure that you have specified a correlation token (e.g., workflowToken) with an OwnerActivityName of your workflow (e.g., Workflow1 or whatever you changed its name to)
  2. In your onWorkflowItemChanged event(s) elsewhere in the workflow, using the same details for the correlation token - i.e., workflowToken and Workflow1.

You will notice when using these events within state machine eventdriven activities, that you can’t select that token in the correlation token dropdown. (This is what normally leads you to choose or create an incorrect correlation token.) However, you can just manually write in the details.

The reason / logic behind this is explained really well, here, in terms of the use of tokens and working out what “scope” different events require.