For Each Loop Quits Early


Userlevel 4
Badge +10

Hi Folks,

I have a site workflow that has a for each loop in it. The loop looks in a list and checks to see if it should create a document in a library for the list item. It used to work well but since we upgraded to SharePoint 2013 when it runs, it quits after 4 loops. We must restart it ever 4 iterations. Any idea why this would happen?

Thanks!

Patrick


19 replies

Userlevel 7
Badge +17

I've seen loops end early after looping through hundreds of items, but not after 4. Is there something in the collection that it is looping with a blank/null/unexpected value?

Badge +7

I agree with @Andrew.  Is there any error messages displayed?  What assignments happen inside the for each loop?

Userlevel 5
Badge +12

Hello,

What version number are you on?

Thanks

Userlevel 4
Badge +10

No, I do not think so. We filter the lookup for the loop on the pertinent data so that should not be an issue. Besides, the very predictable 4 and no more behavior would seem to rule out the randomness of ragged data.

Userlevel 4
Badge +10

Nintex Workflow 2013        

© 2014 Nintex. All rights reserved.

www.nintex.com

Version: 3.1.4.11 - English

Userlevel 5
Badge +12

Thanks - within your For Each action you aren't setting the "Stop Processing" field are you?   This would cause a short cut to the end early if the condition is met.

Userlevel 5
Badge +12

The other item I will ask now is - how many items are in the collection you are iterating over?  You can log out the Count by doing a Collection Operation to make sure 4 items to loop on.

Userlevel 4
Badge +10

Good thought Mike M! I just checked and no, that is not configured.

183260_pastedImage_0.png

Userlevel 5
Badge +12

What I mean is, check the count inside the collection.  The query you are doing that fills the collection prior to entering the For Each may have changed in the number of results it is returning.   Hence the sudden change of iterations.

Userlevel 4
Badge +10

The count varies. Most o0f the time it could be 1 to 5. New hires for the contract are added to the list and a processing flag is set for them. But once or twice a year upon contract extension or contract renewal, all personnel on the contract get a document produced (100-150). This is when we have to babysit the process all day and keep restarting the site workflow.

I am not sure I follow on "log out the count".

Userlevel 4
Badge +10

No error message. The process just ends. There is a lot happening inside the loop. The process looks into the library where the document will be created for an existing document for the record it is processing. If one exists, it moves the existing file to an archive. Then, a new document is created for the processing item.

Userlevel 5
Badge +12

You can use the action Collection Operation which has a method on it called "Count" to store the number into a variable and then use Log to History to see how many items are in your collection.   This way, if the workflow only does 4, you will be able to see in the View History portion of the workflow the number of items the workflow thought it was supposed to process.    If you see 4 but you expected more, then you will know that your Query List action filling the collection prior to the For Each has the issue and not the For Each itself.

Userlevel 5
Badge +12

PS:   Do the Log to History and Count prior to entering the For Each.

Userlevel 4
Badge +10

Oh, I see. The count should be very static as the entire system is managed by one person producing work authorization documents for contract employees. She flags and edits the list and then runs the site workflow.

Userlevel 4
Badge +10

Will do. Plan to test tomorrow. Thanks!

Badge +11

Hi Patrick,

did you have a look at the central administration? Safe looping enabled? Number of loops limit too low? Does ULS show anything odd?

Regards

Philipp

edit: This is the configuration I was talking about (Central Administration -> Nintex Workflow -> Global Settings):

Especially if the number of loops is always the same, it could be related to this configuration.

Userlevel 5
Badge +12

Hey, what's the verdict here?   Did you figure out if the loop is doing what it thinks it should by checking the count?

Userlevel 4
Badge +10

Hi Mike M,

Sorry, I got pulled in another direction and have not attended to this. I will try can get back on it this week and let you know what comes of it. It is a flagged item for me and I will be working it ASAP.

Regards,

Patrick

Badge +11

Please post a screen shot of the workflow.

Reply