Is it possible to run a "foreach" in a statemachine more than just one time?
When the workflow runs "correct" (happy path) the "foreach" runs once (red arrows):
State 1 -> State 2 -> State 4
Now if we take the blue arrow path, the "foreach" does not process the collection a second time, the "foreach" will skiped.
Can someone tell me what is the problem?
State 1 -> State 2 (foreach run) -> State 3 -> State 1 (get all items again) -> State 2 (foreach will skipped) -> ...
Hopefully I explained it clearly
Solved! Go to Solution.
first, awesome illustration. I always wondered how to illustrate such questions but this one was easy to understand and to follow. Will keep this in mind.
Second, in general the for each should run through the collection every time. You could try to clear it before you go into the list query the second time.
Does it change the behaviour?
Thanks for your respond and the flowers
I allready implemented this option (delete the actuall collection befor change the state), sadly this does not work.
Hmm, it might be an issue in your environment.
I created a similar workflow like you have:
I query a list that has 4 elements and iterate through the collection, writing the ID of those elements to workflow log.
If I reject the task in State 2, it goes back to State 1 and does everything again.
In workflow log I can see that the collection was iterated twice:
Can you check if you have the latest build version of Nintex Workflow installed? Maybe there was a problem in an older version. You should have version 126.96.36.199 installed but in my version it works too (188.8.131.52).
We have installed the version 184.108.40.206
My log looks like this:
The collection will filled again, but not processed by the "foreach". its goes direct to the state with the flexi task.
But, in your sample it works, so the error is on my side.
What might help is exporting the query list action and the loop operation into a second workflow and start that workflow from your state machine, but I wonder why it is not working in the first place.