I think this post over on SharePointMag may be what you are looking for.
Summary of Article
This looping workflow has one choice to make among three options each time iterates:
- Is the task complete? If yes, quit. Yeah, we’re done!
- Is this the first time I’m sending a reminder? If yes, send a
reminder and pause one day. Set a flag to indicate that the first
reminder has been sent.
- Is the second or more time I’m sending a reminder? If yes, send it
and pause one day. Increment a counter to indicate how many
reminders have been sent.
(Developer readers here may be thinking to themselves that these seem a lot like states and/or state transitions. You’d be correct to think that.)
To support a design like this, we need to add two columns to our task:
The workflow uses these fields to maintain some information about the task (e.g. was an email reminder sent) as well as to trigger the workflow to run again for subsequent reminders.
It’s important to set the default value of FirstEmailReminderSent to “No”.
EmailReminderCount is simply an number with default value of zero.
With this configuration work complete, let’s see all of this in action by creating a workflow.
Firing up SharePoint Designer, we create the workflow in the normal way (i.e. open up the site with the task list, create new SharePoint content, create a workflow).
The workflow has been named “Daily Reminder,” it’s associated with a list called “Tasks” (i.e. the task list) and here is the key: It’s set to run both when the task is created and when it’s changed. The “whenever an item is changed” bit is very important, as we’ll see later. This setting enable us to leverage SharePoint’s remorseless nature to our benefit.
The first step of the workflow is easy: Stop running if the task has been completed:
The second step is more interesting. This step, labeled “Send Initial Email,” obviously sends the first email. However, it also sets up the subsequent reminder.
Note that this task only runs if our task column, “FirstEmailReminderSent” is equal to No. Since we were careful to specify “no” as this column’s default value, we know this step will run (provided that we got past the first step above).
- First, we send the reminder email.
- Then, we set FirstEmailReminderSent to Yes. This ensures that this
particular step never runs again.
- Next, we pause for one day.
Once our pause completes, we want to start looping. We do this by “poking” the task by changing any field of the current item. When we do this, from SharePoint workflow’s perspective, the item has been changed. Since we checked “Automatically start this workflow when an item is changed,” it starts the workflow all over again. We could pick any field but since we need to “poke” the current item, we may as well derive some business value at the same time. We’ll use the EmailReminderCount field. This way, we can poke it and know how many times the reminder has been sent, killing two birds with one stone.
- First, we create a workflow variable
- Copy the current value of EmailReminderCount to our TemporaryCounter
variable using the “Set Workflow Variable” action
- Use the “Do Calculation” action to increment this by one.
- Finally, update the Task’s EmailReminderCount using the “Update Field
in Current Item” action.
The third and final step looks very similar to the previous this step only runs if the task was not marked as completed and if the first email reminder has already been sent.
Workflow pauses for a day and then increments the EmailReminderCount by one. Performing this update causes the workflow to start over again. Assuming the user never marked the task as complete, SharePoint workflow skips the first steps (since task is not completed) and the second step (since FirstEmailReminderSent is still Yes), landing back here on the third step. It sends the email and pauses 24 hours, pokes itself and keeps looping like this, forever, until the task is completed or it’s deleted.