Question

Right now I've created a few SharePoint Designer workflows in SharePoint 2007, I need to start them all up for each existing list item at (more or less) the same time. I'm not terribly worried about bandwidth as all of them will be waiting for a certain time to elapse on the list anyways (Pause until X Date and x is different for each item).

However is there a tool out there that can iterate through all the list items in a list and start workflows I specify? Or would I have to code this?

Was it helpful?

Solution

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.

OTHER TIPS

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 { ... }
        }
    }
} 

I haven't used this tool before, however it may be what you are looking for:

http://spworkflowstarter.codeplex.com/ - Sharepoint Workflow Starter

According to is description, it can do what you are looking for.

Not sure about the tool John mentioned but you need to aware of SharePoint capacity limits when it comes to workflow. I cannot find the official information for SharePoint 2007, but as far as I remember it's the same as for SharePoint 2010. Official documentation states:

15 is the maximum number of workflows allowed to be executing against a content database at the same time, excluding instances that are running in the timer service. When this threshold is reached, new requests to activate workflows will be queued to be run by the workflow timer service later. As non-timer execution is completed, new requests will count against this threshold. This is limit can be configured by using the Set-SPFarmConfig Windows PowerShell cmdlet. For more information, see Set-SPFarmConfig. Note: This limit does not refer to the total number of workflow instances that can be in progress. Instead, it is the number of instances that are being processed. Increasing this limit increases the throughput of starting and completing workflow tasks but also increases load against the content database and system resources.

I have no idea what you are trying to do here, but you need to check this limit before you start your implementation. Maybe a custom timer job, or SharePoint Workflow Starter can workaround this limitation.

I also had to run a workflow on several items in a list. In my case the workflow is triggered by changes to the items. To trigger the workflow, I used PowerShell to issue a "SystemUpdate" on each item. That will make the workflow run. The script is like this:

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction     SilentlyContinue) -eq $null) 
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$collection = 'XXX'
$site = '/YY/YY/YY/YY'
$list = 'ZZZ'

$spWeb = Get-SPWeb -Identity "https://$collection.QQQQ.dk$site"
$spList = $spWeb.Lists["$list"]
$spList.Items   | where {$_['ID'] -ge 50555} | ForEach-Object {
    write-host("Doing: " + $_['ID'])
    $_.SystemUpdate() 
}

I hope you can use this :-)

Regards Leif

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top