Paul Galvin's (old) SharePoint space [SharePoint

Just another WordPress.com site

Use Semaphores in SharePoint Designer Workflow to Prevent Endless Loops

It’s possible to cause an endless loop in a SharePoint Designer workflow.  A common implementation pattern like this causes the problem:

  • Create a workflow and associate with a list.
  • Indicate that it should start on create of new items and update of existing items.
  • A step in the workflow updates a field in "Current Item".
  • Since the current item changed, the workflow starts anew.

To prevent this endless loop, implement a simple semaphore:

  • Add a site column (or column to the list/library if you’re not using content types).
  • Hide it from the edit page (easy to do if a site column via its properties, not as easy if a list column).
  • In the workflow, check to see if the value of the semaphore column is blank.
  • If it is blank, set it to a non-blank value and proceed.
  • If is is not blank, exit immediately.

This can become a fairly nuanced solution, depending on business requirements and so forth, but it’s been a workable pattern when I’ve needed it.

</end>

Technorati Tags:

Subscribe to my blog.

Advertisements

6 responses to “Use Semaphores in SharePoint Designer Workflow to Prevent Endless Loops

  1. Sanjeev April 24, 2008 at 1:20 pm

    To take this suggestion one step further –
     
    I created a separate custom list called Notifications and created a column for each workflow I have. I was having trouble when sending emails – causing a loop – and mail bombing my inbox.  So now, I have the workflow check the status of the column (of the same name) BEFORE the email is sent, and then change the value AFTER the email is sent.

  2. David June 16, 2008 at 6:10 pm

    Maybe I\’m missing something here, but that seems to work the first time, but never again.
     
    When you set the field to Non blank, it will exit the secone time its called. That\’s good.
    But when you update the item, say 15 min later, then the field is still set to non blank, thus, it exits without running the workflow… am I missing something.
     
    I hope I am, as I need to work.
     
    As an FYI, I have a less elegant solution.
    Rather than setting a flag on the item itself, I create an entry in a new list. Then the second time through, I delete it. That acts as the flag, but I would like a more elegant solution if possible.

  3. Dave July 30, 2008 at 5:53 pm

    Paul,
     
    Please responsd to this. Does your solution work if the the list item is edited more then one time?

  4. Unknown November 3, 2008 at 11:52 pm

    ショッピング枠現金化するので誰でもかんたんにカードでお金をおつくりできます♪ご融資などではありませんので審査や面倒な手続きは一切ございません! ご返済方法は一括・リボ・分割(最高20回)・ボーナス一括などからお選びいただけます。 

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: