1

One of our users has a custom list with 50+ items which contain of a UID and a contact. In a different custom library they have a lookup field where users must select one or multiple items. Based on the items that they have selected, they want to send e-mails to the contacts as selected and automatically create items in a third custom list.

We have been *granted* the task to make this work, however we do not have access to the server itself and have only been granted Site Collection Administrator permissions. I've started building a workflow in SharePoint Designer 2010, but am lacking any form of looping method.

Does anyone know a method of looping through the multi-lookup field, getting the values, and doing things with the values? I'd hate it to make 50+ checkboxes and having to explain them how to work with it.

0

So I just figured out a way to do it, after a lot of trying and error fixing.
For ease of explaining I've named the column that holds the content for the lookup "SourceList"

Preparation
1) Create a loop list, containing three columns: Title, cnt, LoopGUID
2) Create one entry with the title "Count", a cnt of 0 and the LoopGUID "idle"
3) Add a column "LoopGUID" to the SourceList and fill it with the default value "idle"

Three looping workflows
Workflow #1
4) Create a Workflow on the custom list that the users fill in containing the selection(s) that runs on creates and edits
4.1) If "Loop list:cnt" equals 0
4.1.1) Pause 5 minutes
4.2) If "Loop list:cnt" equals 0
4.2.1) Pause 5 minutes
4.3) If "Loop list:cnt" equals 0
Stop workflow
4.4) Update "Loop list", set cnt = 1, LoopGUID = CurrentItem:GUID where title equals "Count"

Workflow #2
5) Create a Workflow on the Loop list that runs on edits
5.0) Create a local variable (String) called LookupValidator
5.1) If CurrentItem:cnt > 0
5.1.1) Set LocalVariable:LookupValidator to SourceList:GUID, where SourceList:LoopGUID equals "idle"
5.1.2) If LocalVariable:LookupValidator is not empty
5.1.2.1) Update item in SourceList: SourceList:LoopGUID = CurrentItem:LoopGUID, where SourceList:LoopGUID equals "idle"

Workflow #3
6) Create a Workflow on the SourceList that runs on edits
6.0) Create a local variable named cnt (Number) and a local variable named LookupValidator (String)
6.1) Set LocalVariable:cnt to LoopList:cnt, where Title equals "Count"
6.2) Calculate LocalVariable:cnt plus 1 and store in LocalVariable:cnt
6.3) Update LoopList:cnt = LocalVariable:cnt, where Title equals "Count"
6.4) Pause for 1 minute
6.5) If LoopList:cnt equals LocalVariable:cnt
6.5.1) Update LoopList, set cnt = 0, GUID = "idle" where Title = "Count"

One workflow to do what you want
Workflow #4
7) Create a Workflow on the SourceList that runs on edits
7.1a) If CurrentItem:LoopGUID is not empty
7.1b) And CurrentItem:LoopGUID not equals "idle"
7.1.1) [Do your actions here]
7.1.2) Pause for 1 minute
7.1.3) Update CurrentItem:LoopGUID = "idle"

The pauses will make sure that the list is automatically reset when all changes are complete. The 3 times 5 minutes wait on Workflow #1 is to give the workflow multiple chances of going through the entire sequence before giving up, just in case more then one item is modified within 4 minutes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.