3
votes

I have 2 SharePoint lists, and I have to copy all items from List1 to List2.

On List1 there is a boolean field (defaults to 'no'), a text field and an associated WorkFlow which triggers on modifications.

The WokFlow simplified:

  1. Copy current item to List2
  2. Set my boolen field to 'yes'
  3. Search for an item with boolen field 'no', set its text field to 'copy'

I start the process by modifing an item in List1, then it will copy itself to List2, modifies an another item, and so on... until there is any item with a boolen field set to 'no'.

This works perfectly for 10 items, but then it fails. Item 10 modified item 11's text field to 'copy', but item 11's WorkFlow does not started. I've tried it serval times, and always stopped after 10 copies.

I've Googled and MSDN'd. The best solution I've found is to pause for 1 minute in the WorkFlow. But I have thousands of items...

Has anyone any advice? I even cant find any limit in the SharePoint 2010 server that defaults to 10.

Thank You!

3
Very weird indeed - I don't know of any limit around 10 either. Something to do with paging? But Workflows usually don't care about paging.Dennis G
I think there is a concurrent workflow limit which is either 8 or 15 by default. I don't have a SP2010 here right now, but I think it's in Central Admin > Web Application Management > Select your web app > Resources/Throttling/Limits/Whatever it's called. See this for additional info: stackoverflow.com/questions/6332070/active-vs-running-workflow - not 100% sure it applies, but somehow I think throttling is hitting you. Also check the ULS Log File (14\LOGS) for information about workflow throttling.Michael Stum♦
Forget about workflow when you need to acomplish something as simple as copying items from one list to another. You are misusing a mechanism that's not supposed to replace a 'plain old for cycle'. Regardless of what's the source of the error.Ondrej Tucny

3 Answers

0
votes

You are triggering a hardcoded resource throttle in SharePoint 2010 due to the speed on the workflow. It's there to prevent the system from becoming unresponsive during workflow operations. Code in an application page or timer job will get around this limit but it's not recommended to have a greedy operation that cause the system to become unresponsive to users.

0
votes

You can do CAML batch methods.

somethig like this:

    void UpdateList()
    {
        StringBuilder methodBuilder = new StringBuilder();
        string batch = string.Empty;
        string newValue="mmmm";
        string updateColumn = "SampleColumn";


        try
        {
            string batchFormat =    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                                    "<ows:Batch OnError=\"Continue\">{0}</ows:Batch>";
            string methodFormat = "<Method ID='{0}' >" +
                                    "<SetList>{1}</SetList>" +
                                    "<SetVar Name='Cmd'>Save</SetVar>" +
                                    "<SetVar Name='ID'>{2}</SetVar>" +
                                    "<SetVar Name='urn:schemas-microsoft-com:office:office#{3}'>{4}</SetVar>" +
                                    "</Method>";

            using (SPSite siteCol = new SPSite("SampleSite"))
            {
                using (SPWeb web = siteCol.OpenWeb())
                {

                    // Get the list containing the items to update
                    SPList list = web.Lists["SampleList"];
                    string listGuid = list.ID.ToString();
                    SPListItemCollection allItems = list.GetItems();

                    // Build the CAML update commands.
                    for (int i = 0; i < allItems.Count; i++)
                    {
                        int itemID = allItems[i].ID;
                        methodBuilder.AppendFormat(methodFormat, itemID, listGuid, itemID, updatedColumn, newValue);
                    }
                    web.AllowUnsafeUpdates = true;

                    // Generate the CAML
                    batch = string.Format(batchFormat, methodBuilder.ToString());

                    // Process the batch 
                    string batchReturn = web.ProcessBatchData(batch);

                }
                //done
            }

        }
        catch (Exception ex)
        {
    //show the error
        }

    }

You can create batch methods for create , delete and update items on lists and document libraries.

Refs:

http://msdn.microsoft.com/en-us/library/office/ms437562%28v=office.15%29.aspx

http://msdn.microsoft.com/en-us/library/office/ms459050(v=office.15).aspx

0
votes

if you want to change workflow concurrent execution limits ....

For check limits:

 Get-SPFarmConfig | Select WorkflowPostponeThreshold 

For change

 Set-SPFarmConfig -WorkflowPostponeThreshold 50 

Timer service process items ( workflows continuations) on batch sizes

 Get-SPFarmConfig | Select WorkflowBatchSize 

 Set-SPFarmConfig -WorkflowBatchSize 150