Skip to main content
Nintex Community Menu Bar

I know this is going to be a very basic question, but here it is.  The "For Each" workflow action isn't work for me.  It's probably because I switch back and forth between several different systems, languages and workflow engines.

 

I'm trying to set up a workflow that looks at a "Deadline Date" in a list evaluates the due date and sends out notifications to the owner of the item.  The list has numerous items (5 or 6 hundered) that need to be evaluated, however I can only get it to evaluate one item in the list.

18246i14968F979262C3BC.png

 

 

To really make any headway with this problem, at minimum we'd need to see how the For Each action is configured. Ideally though, we should probably look at the Query, Collection Action, and the If Statement inside of the loop to really get an idea about what's happening. 

Looking at the workflow actions from this far out doesn't provide any clues that would be useful. 


I was going to provide that, but neglected to.  See the attached document for screen shots. I'm certain that my logic is off and that it is going to be something really simple (stupid).


One of the immediate things I see is that in both you Collections Operation and For Each loop, you're referencing a variable called ColIDs, but I do not see it ever being set to anything. 



 



How is this variable's value set, and from where? 



 



 


Hi,



What is the filter condition in "Query list" action?



I saw the document with screen shots, in "ForEach" you are checking every item if the condition met, instead you can have your conditions in "Filter" section of "Query List" action.



 


Here is the filter for the query:



 





 


Not sure if it was missed because of the secondary question, but did you ever find out where that variable I asked about was being set, or what it contained? 


The COlIDs is stored in the Index variable.


Nah. I'm asking where the colIDs are being set



 



I see where they are used



 





 





 



But nothing shows this variable actually being set...



 





 



If your For Each loop is pointing to a variable containing nothing, it's not going to loop. 


The Item Ids are created each time someone creates a request.  So they are created in the list by the user.


Perhaps I'm asking you the wrong way so I'm going to just start from the beginning, using your initial question / problem, and walk through what I'm trying to get. 




Your Problem



 



You wanna iterate over several SharePoint List Items using a For Each workflow Action, however, when you run the workflow, it seemingly only ever affects just 1 item.



----



 



How A For Each Loop Works



 



1. The For Each Action works by assigning a Collection (variable) as the "Target Collection". The Target Collection is the 'group' of things that your For Each loop will iterate over. If there are 10 *things* in the Target Collection, then your loop should loop 10 times. 



 



2. Every loop, your position within your collection of *stuff* is being tracked, and the current value you're on is stored inside of the variable you declare as your variable to "Store Result In"



 



3. Additionally the position is also stored and you can optionally store it to a variable called "Index". 



 



Below is an example of how a For Loop can be configured: 





 



I have a collection of XML that I'm iterating through, and each chunk of XML will be stored inside of a variable called "var_Local_ProductXMLInfo_Item" each loop. Additionally, the index of where I'm at inside of that collection is stored in the variable "var_Current_Index". 



 



So, if I have a collection variable called "my_Collection" that has the following strings inside of it: 




"Red; Green; Blue"



 



and I store the results in a variable called "current_Color", and the index in a variable called "current_Index", then the values for those variables will change as follows: 



 



Loop 1:



current_Color = "Red"



current_Index = 0



 



Loop 2:



current_Color = "Green"



current_Index = 1



 



Loop 3:



current_Color = "Blue"



current_Index = 2



 



(Note: in programming and for this nintex for each workflow action, the FIRST item is stored in the position of zero (0) and NOT one (1)!!!! So even though there are three items in my collection, the indexes used are 0, 1, and 2!) 



----



 



What I'm Asking You For



 



Now that we have those factors out of the way, let's get back to the information you've given us. You have shown to us that you are using the For Each loop, but you have never once described how the Target Collection (colIDs) is being set. Because of this, we have NO IDEA what is actually being looped over. If we do not know what that variable contains, then it is literally impossible to help you.



 



You have said "Item Ids are created each time someone creates a request", but this means nothing to me as I do not know how this pertains to the variable you have assigned as the Target to your For Each loop (colIDs). 



 



You have also said "The COlIDs is stored in the Index variable.", but this also does not mean anything in particular to telling me how the VALUE of the variable colIDs is being set! 



 



As far as I can tell, based off of the information you've shown to use, you are either giving it a value manually, or you are simply not setting its value at all, which is what's causing your loop to not work. 

While the mystery of the colIDs variable is not the only thing wrong with the workflow, it's one of the most crucial as a loop will never work correctly if the collection its targeting doesn't contain anything pertaining to the qty of items that the workflow designer is hoping to iterate over! 



 



Please look at your workflow, and see if you can find how the value of the colIDs variable is being set. If you want to attach pictures, or just attach the entire workflow, please do. Though do be warned that you should remove any information in the workflow that might be sensitive or classified as this is a public forum. 



 



I know that this is wordy, but there is literally nothing to be done until its sorted. 



 



Thank you. 


Reply