I'm using a simple Workflow for demonstration purposes:

enter image description here

Init sets State1. State 1 waits for item changed and set's state 2. State 2 waits for item change and finishes the workflow.

The problem: When running this workflow and changing the item, the Workflow runs right through to the Completed state, it doesn't stop at Step 2 (stateActivity2).

I read that the onWorkflowItemChanged activity needs the Workflow correlation token to work. I have made an adjustment as in to create a new correlation token per state (via InitializeWorkflow) and use that correlation token in each state. This way the workflow "stops" in each state, but is this the correct way to go about things?

All I want is for the state machine workflow to wait for item changes and upon that (and some code) continue to the next state.

Basically my question is: How to use a onWorkflowItemChanged in a State Machine Workflow?

Tried to use the CallExternalMethod / HandleExternalEvent approach (see comment below or here: Capturing OnItemChanged) - to no avail, Events are just not being called at all - one should be able to use the OnWorkflowItemChanged activity what else is it for?
Just to add: I verified exactly this behavior on a totally different SP2010 system - my approach as shown in the image must be wrong, but (here comes the kicker) it works in SP2007 (multiple states with a OnWorkflowActivated activity each)

  • 1
  • Have you been able to find an answer you can give for this, or are you able to edit the question with any more information?
    – Alex Angas
    May 18, 2011 at 1:04
  • There does not seem to be a real solution - it rather seems to be a bug in SP2010. Microsoft doesn't let customers file a bug via MS Connect hence one can only inform them via a Support case. I'm not willing to spend a support case (which might be refunded if really a bug) for this. Yes, I found a workaround. It is REALLY ugly, but it works. Will post later today.
    – Dennis G
    May 18, 2011 at 13:35
  • 1
    As it's a bug, can you please leave an answer explaining this and your workaround if you have one? Then you can mark this question "answered". Also, a suggestion on reporting this to Microsoft is to post it on MSDN forums and state clearly that it's a bug.
    – Alex Angas
    Jun 1, 2011 at 5:18

1 Answer 1


So it seems I found two solutions, the workaround and the real solution:


  1. Log start message when list item created;
  2. Log one piece of message when list item updated for the first time;
  3. Log another piece of message when list item updated for the second time;
  4. Complete the workflow.

Downloadable test project with this method: Download (via MSDN forums)

Solution: Rather stupid, but I think it is the problem: LogToWorkflowHistory Activity.

In all my example workflows I created a "item changed" log entry after the item changed. Once all LogToWorkflowHistory activities were removed (and done in code via SPWorkflow.CreateHistoryEvent) - the workflow did not continue through the next state after finishing the first. I am assuming that somehow the LogToWorkflowHistory activity triggers an update of the item, so after the first ItemChanged a Log entry is provoked and an item change, hence the next state also thinks that the item changed.

The simple solution you can see in the following example, in my live workflows I have a few Code Activities here and there - but all LogToWorkflowHistory are gone.

enter image description here


I forgot to mention: Also the correlation token of the ItemChanged Activity is not set to the workflowToken, but to a specially created token within the state. In the Initializing Event of the state a have a WorkflowInitializing Activity where I set a custom token, this token I then use in the ItemChangedEvent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.