Friday, April 8, 2011

Avoid firing OnWorkflowItem changed for changes made by the workflow

I have a state machine workflow that responds to changes in a list item. The workflow also updates the list item; is there any way to avoid firing the OnWorkflowItem changed event when the changes were made by the workflow?

From stackoverflow
  • use the List item's .SystemUpdate() method instead of Update().

    • Oisin
    Robin Clowers : This did not seem to work, the MSDN documentation on SystemUpdate (http://msdn.microsoft.com/en-us/library/ms461526.aspx) says: "When you implement the SystemUpdate method, events are triggered..." My OnWorkflowItemChanged event still fired when I used SystemUpdate.
  • So I found a workaround for this, but it's pretty ugly, hopefully someone has a better answer.

    Rather than having one state do an update and then wait for the event, I split it out into two states. The first state updates the list item, catches that on change event, and transitions to the second state which waits for the a change from the user.

0 comments:

Post a Comment