Sharepoint - Easiest way to start SharePoint workflows on a bunch of list items in SharePoint 2007?
No need to introduce an app written by someone else to do this. It can all be done through the UI.
This is what I do for items I need to process in bulk with a workflow. Create a simple number column that acts as a trigger with a default value of 0. In my workflow, I put in an If trigger column = 1 do what I need it to do.
In datasheet view, I expose the trigger column, set it to 1 and fill it down, firing off the workflow for each item.
At that point the if trigger portion can be removed from the workflow or change the default value of the column to 1 and hide it. Then new items submitted will process normally.
I've done something similar using a custom timer job to trigger a workflow on each item in a list. The bit of code which does that looks like this:
using (SPSite siteCollection = new SPSite("...Site..."))
{
using (SPWeb site = siteCollection.OpenWeb("...SubSite..."))
{
SPList taskList = site.GetList("...ListPath...");
SPWorkflowAssociation workflowAssociation =
taskList.WorkflowAssociations.GetAssociationByName(
"...WorkflowName...",
System.Globalization.CultureInfo.CurrentCulture);
foreach(SPListItem item in taskList.Items)
{
try
{
siteCollection.WorkflowManager.StartWorkflow(
item,
workflowAssociation,
workflowAssociation.AssociationData);
}
catch { ... }
}
}
}