Timer Workflows
It is often a requirement of a Workflow in SharePoint to monitor and respond to various dates such as a start or due date.
If the timer is not the main function of a Workflow, it can be created as a separate Workflow to that both can run in parallel with full functionality.
Looping Timer Workflows
To have a looping timer workflow (eg. send a daily notification/reminder until a specific condition is met), the workflow must start when an item in the list is changed, and when it is created depending on the scenario.
At the start of the workflow, test if the required condition has been met, and stop the workflow if it has. If the condition has not yet been satisfied, the workflow can continue.
As the workflow will initiate after an item is modified, it is possible for multiple instances of the same workflow to be initiated. To prevent this, a custom (boolean) field is added to the list which is used to determine if an instance of the workflow is already running. When the workflow starts, it first tests if the value of a custom field (eg. "timer_waiting") in the current item is set to true/yes. If true, another instance of the workflow is already running and the current can be stopped. If false, the custom"timer_waiting" field can be set to true/yes to stop new instances from starting until the current is complete.
If the workflow is to continue, perform the required date calculations (current date + 1 day), store in a workflow variable, then wait until the date determined. Send the email, or perform other actions after the workflow has finished waiting (next workflow step).
To complete the workflow, set the field in the current item "timer_waiting" back to false/no to allow a new instance of the timer workflow to start.
If the SharePoint (MOSS 2007) Server has no service packs installed or Service Pack 1 only, updating the field in the current item workflow will cause another instance of the workflow to start, creating the looping functionality. If service pack is installed, a separate list must be used to trigger the first again to enable looping workflows.
For more information about looping workflows in general, as well as the changes to looping workflows made when Service Pack 2 is installed, see Service Pack 2 prevents an on-change workflow from starting itself.


0 comments:
Post a Comment