Starting-Stopping Workflows and Creating Loops

Nov 4, 2009 at 1:04 PM

I have been working on a way to create what effectivly amounts to a looping workflow using the Start Workflow function.  Effectivly what I'm trying to do is create a workflow that checks the date and if the date is today or later, it changes a field, else it pauses for 24 hours and checks again, effectivly looping.   I do this using two seperate workflows that each start the other when it ends.


Workflow 1.

Step 1: Check conditions of the workflow using If and then statements.

Step 2:  Start Workflow 2.

Workflow 2

Step 1:  Check Conditions of the workflow using if and then statements.

Step 2: Start Workflow 1

You set Workflow 1 to start up on creation only.

So a new item is created and effectivly an endless loop runs.

The problem is that the Star Workflow functions creates an error on the second go around.  Another words the Workflow 1 starts and when it ends it kicks of Workflow 2. Then Workflow 2 ends it should start Workflow 1 again but it does not, instead getting the following error.

Microsoft.SharePoint.SPException: Exception from HRESULT: 0x8102009B ---> System.Runtime.InteropServices.COMException (0x8102009B): Exception from HRESULT: 0x8102009B

This error is discussed here. which suggests that Workflow 1 although it says complete is not actually complete by Sharepoints logic (a complete status apperantly means the workflow is still running its just in a complete status so it cannot be "started again".

I'm currious if anyone has had any luck creating looping workflows like this that check dates and fields for information and take actions as a result.  The best I have ever acomplished is by using the change method which is effectivly setting all workflows to restart whenever any field is changed.  Programically however this is very unsound as it creates a ton of versions of the record eventually locking up logs in the database requiring manual maintenance or maintenance plans.  The best way is for the workflow to start each other with logic, but given the error and how Sharepoint seems to handle complete workflows Im not really sure what else I can do here, though it would be extremly useful to make this work.

Feb 26, 2010 at 8:56 AM

Did you find a solution?

How to check if a workflow is already running on an item?