SharePoint 2010 State Machine workflow onWorkflowItemChanged firing multiple times

Fri, Sep 28, 2012 One-minute read

If you’re designing a SharePoint 2010 workflow, particularly a state machine, you may base the workflow activities around an item in a list. Particularly, you may want the workflow to carry out activities when the item is changed by the end user.

This is a relatively straight-forward task, but one thing you will quickly encounter is that if you have multiple states, and each one handling the onWorkflowItemChanged event, you’ll notice that the event will fire once for each occurrence of your handler. So if you had 3 states, and each one has an onWorkflowItemChanged event, then your state that is handling the event will receive it 3 times. This is clearly undesirable and quite frankly strange behaviour.

Microsoft have acknowledged this behaviour, and in typical style, have said it is by design - whilst offering up a workaround.