Iterate through a Sharepoint List

Programming is the Microsoft world is full of surprise. I have learned from experience that the easier its sounds the more difficult it may be. That is why I avoid anything that is too easy in the Microsoft world. The other day i wanted to just iterate through a custom list  using worflow and to my surprise there are no easy ways to do that (there are no “for” nor “while” loop..).  Note that I am only a seasoned sharepoint developer/designer who just wanted to get a little project out of the door.  After googling around I found the following article. Once I understood the concept I was able to get everything up and running.

Read the following from start to finish
http://office.microsoft.com/en-us/sharepointdesigner/HA102378301033.aspx

It is easy to dismiss this section below from the article for me it was the most important.

Whenever a lookup does not find matching data, it returns the string ?????. For example, if you define a workflow lookup to select the value of the Title field from the Tasks list where the Assigned To field equals "John", but there is no task assigned to "John", the lookup would return ?????. To resolve this, you can open the appropriate lookup and change the filter criteria so that the query returns a matching item.

Attach your workflow to the list that is most like a master list and that has more or less all the data that can be used in your workflow. This way you can use a lot more values from the current item in your lookups rather than creating complex lookups to get values from other lists.

Whenever a lookup encounters a variable that does not have data in it, it returns the string ****. To resolve this, open the workflow and make sure that the variable is set to a value (or initialized).

To clear the contents of a Define Workflow Lookup dialog box, click the Clear Lookup button in that dialog box

Taken from directly from  Microsoft.

Other Resources

http://www.sharepointdesignerworkflow.com/list

http://sharepointsolutions.blogspot.com/2008/05/looping-through-items-in-sharepoint.html

Let's share thisShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn