How to have multiple instances of a workflow update a single list item - SharePoint 2010 Workflows RRS feed

  • Question

  • I have a list called "Tasks"with a number column called "Count".  

    On the "Workflow Tasks" list, I have a workflow that gets triggered on item added or item changed. When a workflow task is created/edited, the workflow checks the status of the task and either adds 1 or minuses 1 to the "Tasks" "Count" column. 

    If I add a single task to the workflow task list, the workflow picks it up and adds 1 to the "Count" field perfectly. However, if i add two tasks to the workflow task list, one after the other, the second task's workflow results in an error. 

    It's almost like i'm unable to update the "Count" field multiple times. I assumed that the row was somehow "locked" while the first instance of the workflow was updating it, so I added a pause, which didn't help. (I guess because the 2 instances pause at the same time.) I then added another column to the "Tasks" list called "Busy" and set this to "Yes" while the first instance updated the row. When the second instance runs, it first checks if "Busy" is "Yes" and if so, it pauses for a duration and then carries on. This still does not work.

    Is my assumption of row locking correct? Or what am I missing? 


    Edit: I don't have access to the error logs and the error simply states "An error has occurred in [Workflow Name].
    Tuesday, September 6, 2016 12:54 PM

All replies

  • Back in the Ye Olde Days of programming, when locking wasn't handled for you, you would have to create your own "semaphore".

    For example, a field in a list set to either 1 or 0. When you need a resource, you check the semaphore. If it's 0, then you're free to acquire the resource. If it's a 1, then you know that it's busy, so you have to wait, cancel, or fail the operation. (In college dorms, the "Sock on the door handle" was the international semaphore for "No room at the Inn". Same concept.)

    When I make a semaphore, I prefer to log WHO has it locked, and WHEN they locked it, but a simple binary will do.

    So, in your case, the 2nd WF will see that the resource is busy, and you could use a "Pause Until" action to have it wait a minute and try the semaphore again.  Rinse, lather, repeat.

    Steve Clark, MCTS
    Easy Bins Roll-off Dumpster Rentals in Northern VA
    Specializing in:
    Driveway-sized, roll-off dumpster rentals in Fairfax VA | Dumpster Rentals for Junk Hauling in Springfield VA
    Roll-off Rental Dumpsters in Annandale, VA

    Tuesday, September 6, 2016 8:14 PM
  • Thanks Steve. I'll give this a try and give you feedback. Your response was most entertaining. :) 
    Wednesday, September 7, 2016 2:24 PM