Workflow: Error operating on collection variable. Index property is greater than the number of items in the collection.


Badge +10

Hi

I'm trying to get an email alert to show the following fields:

So I've created a For Each Loop:

For Each

with twelve collection actions within to start to build up the fields. When I tested it (before I went any further) the workflow errored at For Each with:

'Error operating on collection variable. Index property is greater than the number of items in the collection' a snapshot of the collection actions is below, what am I doing wrong?


17 replies

Userlevel 5
Badge +14

how do you populate single collection variables?

do they all have just the same number of elements?

Badge +10

Earlier in the Workflow I have a Query list action which queries 17 fields, so is the problem that the number of fields in

the Query action doesn't match up with the Collection operations?

  

Userlevel 5
Badge +14

so is the problem that the number of fields in the Query action doesn't match up with the Collection operations?

no.

your query seems to be correct, I was afraid you popolate each collection variable with a separate query so you end up with different number of elements in each of them.

can you post configuration of 1 or 2 collection operations how do you read values from collections?

Badge +10

No problem, here's a few of them:

Userlevel 5
Badge +14

this seems to be correct as well.

do you perform any other operation on any of collection variables between query list action and for each loop?

especially if it is an action that might change its content.

can you proof-check that you haven't accidentally configured different collection variables in query list action and respective collection operation?

or perhaps  index variable?

or collection operation function?

if everything is configured correctly, then I would probably tried to disable all the collection operation actions within the loop and run workflow whether it passes through or not.

then I would tried to enable collection operation actions one by one and tested which works and which one fails.

Badge +10

I tried what you suggested and disabled each Collection operation, then enabled them one by one and ran the workflow. It worked fine until I got to the 9nth Collection operation pictured below:

The text_cost_centre variable is a Single line of text variable, it stores a series of numbers and letters. The error t's throwing up is the same as before 'Error operating on collection variable. Index property is greater than the number of items in the collection.'..

I disabled this Collection operation and went onto the next but got the same error.

Badge +10

The Cost Centre Field in the list is a Drop Down Field. I changed the variable that the result is stored in to a Choice variable but still got the same error. 

Userlevel 4
Badge +10

Try disabling the 8th Collection operation and see if the 9th works.

Badge +10

Yes tried that and it errors. I'll post the full Loop workflow,

Badge +10

Badge +10

I think I've got to the crux of the problem. It's the Cost Centre list. It's a separate list that is being populated via a Data source in the properties. I've used the lit again on another form and got the same problem. Question is how do I get round it, or do I just recreate the list?

Badge +10

Might it have something to do with the amount of items in the Cost Centre list there are approx. over 50?

Userlevel 4
Badge +10

Nope... 50 should be easily handled.

Userlevel 4
Badge +10

Is the Cost Center value being populated into a field in the list or a only to a control on the form?

Test the variable (verbose logging) to see if the cost center is making it into the variable.

Userlevel 5
Badge +14

It worked fine until I got to the 9nth Collection operation

ok, step forward we have guilty one happy.png

The Cost Centre Field in the list is a Drop Down Field.

is it a dropdown for lookup or choice field?

It's the Cost Centre list. It's a separate list that is being populated via a Data source in the properties.

can you explain/document what you mean with this?

by the screenshot you recently posted for 9th collection operation, you reference there 'col-costcentre' collection.

however, query list operation seems to store 'Cost Centre' into 'col_cost_centre' collection.

so, these seem not to match!

have you checked the configuration as I advised above? likely you experience the same misconfiguration for 10th collection operation...

Badge +10

Boom, yes you were completely right I was using two different collection variables! Stupid! When I took a step back and re-read your post I realised! Thanks again

Userlevel 5
Badge +14

great!

have you got it working? if so please mark correct answer.

Reply