Iterating through a sharepoint list

  • 30 October 2009
  • 3 replies
  • 2 views

Badge +8

Hi,
what`s the best way to design a workflow which iterates through a sharepoint list and executes an event for the list items?
Thx


3 replies

Badge +10

Can you give a more detailed description of the scenario.  I've done similar things in the past but it does depend on when the workflow is started.  Is it scheduled or should it start whenever someone adds a new item to a list or changes a list item etc.


 

Badge +8

something like a sheduled workflow. For example that every day one process is started to loop through a list? There is one interesting blog by Russel...I think this will solve my problem
http://www.k2underground.com/blogs/pitchblack/archive/2008/08/26/looping-through-an-activity-for-each-item-returned-from-a-smartobject-list.aspx

Are thre any other possible solutions? Sheduled workflows are not possible out of the box.

Badge +10

What I've done in the past is to create either a Windows Service or else just a dll that is scheduled using Windows Scheduler that will query the SharePoint list using CAML and return the matching results into a dataset that then calls the SourceCode.Workflow.Client APIs to lanch a separate workflow instance for each record in the datatable.  This works fine but then you have separate components outside of your K2 process and forms you need to monitor.


I've also toyed with having a K2 Process that has an activity that queries the list once every day and it loops back onto the querying activity (you can prevent continuous querying by adding a 1 day delay to the start rule of the querying activity).  Any matching results would then use the blog post technique you linked to above to start off a separate process instance.  If the query of the SharePoint list isn't complex then this would be potentially a no code solution to the scheduling problem.  However, I haven't gone this route as in the past I've heard that K2 doesn't recommend using this technique although I haven't heard what I thought was a good reason not to if its only running once or a few times a day. 


If anyone has any experience using this approach and can add some pros and cons approach please join in.


Regards,


Tim


 

Reply