views:

70

answers:

1

We have a SharePoint site that displays a calendar and manages appointments etc.

We are trying to automate several aspects of this system via workflows.

Indvidually each workflow works ok.

The problem is that we want them to run automatically when an item is modified. But sometimes a workflow itself modifies another item - which in turn triggers the workflows....

How do you avoid these race conditions?

+2  A: 

Heads up: I haven't tested this with workflow specifically

For SP events you can do this programmatically through the list item event receiver.

When you attach the event receiver to the list you can explicitly disable event firing for a particular sequence. This stop the subsequent events from firing as a result of the initial event.

This behaviour should carry over to workflow, as long as you launch the workflow from the event receiver.

public class ListItemEventReceiver : SPItemEventReceiver
{
    #region SPItemEventReceiver Interface
    public override void ItemAdded(SPItemEventProperties properties)
    {
        this.DisableEventFiring();

        // trigger your workflow here

        this.EnableEventFiring();
    }
 }
Mark