Tuesday, September 7, 2010

Workflow iteration through list

I am sorry to say that there is no out-of-box way to let a workflow action or lookup iterate through a list.

For example:
If you specify the target email recipient in an email workflow task to be a specific column of a list where the items meet a specific criteria (i.e. active) then the workflow will only select the first occurrence. Quite frustrating.

Workaround:
There is a laborious workaround for it though.
  1. Create a new workflow which manually gets kicked off by the original workflow instead of having the original workflow send an email.
  2. Add a column to the list called something like "SendStatus" and its default value is "ready".
  3. The new workflow selects items with status "ready" and then sends email and then changes status to "sent".
  4. Hook up the same workflow to this list's change event. This way the workflow will iteratively execute and each next time it executes, it will select the next item because the previous item's status prevents it from being selected.
  5. Once there are no more items available, change all statuses back to "ready".

No comments:

Post a Comment