I have tried set For Each loop to look for results and store in collection, but its turn out that if one of the result met the criteria, it will proceed to next step. How to set For each loop to wait for all result to meet criteria (i.e. All items in collection showing 'Yes', not just 1 Yes) before proceed to next step?
When you say "all items in a collection" does this mean that you're trying to wait for several different SharePoint items to reach a desired 'state' before proceeding on with some step?
The For Each Loop isn't really able to do what it is you're attempting to accomplish (because if you're iterating over a collection, all of values have already been set and are not "active". You're looking at whatever value they were at the time of building the collection), but there might be another way depending on a few circumstances. If you could describe your scenario, I might be able to help.
Thanks for quick reply!
My scenario is that if I have several batches per below list and I want all items (1,2) in Batch A to be confirmed as 'Yes' then update Ready to proceed column (by using Update multiple item action) to be 'Yes'.
|Batch||Item||Confirm||Ready to proceed|
Not sure are there any action can help on above underline step? to collect and wait for the desired outcome before proceed to next step.
So I had written a reply here earlier but it wasn't sufficiently good, so I deleted it!
Firstly to answer your question regarding figuring out if:
all items (1,2) in Batch A to be confirmed as 'Yes'
You can certainly do a few things that would let you track the current 'state' of your item by using a State Machine action. Pairing that up with a Task that controls the Confirm column value, you could easily wait until whatever task at hand was finished, and then afterwards change the state and do any number of things to the item the workflow is working on.
(Note: in this video, while they show you how to make a state machine workflow and run through the ropes of how it works, they don't bother to go into the part involving assigning tasks... and there does not seem to be any immediately good videos on assigning tasks using Nintex Workflow that don't involve using the Assign Flexi Task action for multiple users... if you need help regarding tasks, yell, and I'll write up a post about them, as the current state of available material is legitimately abysmal)
However, figuring out when those separate items have finished their respective workflows is an issue because workflows (running on items) don't really have a good way of talking to one another. What people want to happen is:
While that method *can* work in certain scenarios, there is always the risk that the following happens:
Because the two items completed closely together, they both see the other item as 'Completed' and now both do the same Final Action, likely, incorrectly. This is what's known as a Race Condition. Additionally, this problem will only further become likely with the more items that need to check against one another as it increases the chances that during a check, any given item's status could change before or after the period when the check is being processed.
Depending on the exact nature of what it is you're trying to get done after all of these items complete will ultimately determine how good of a solution the above approach is, or if we can come up with something else.
That leads me to a few questions
I know that this post is long winded, but I just wanted to be precise and thorough as I myself have walked a particular variant of this path and know its pain (see: https://community.nintex.com/t5/Nintex-for-SharePoint-Forum/Best-Practice-Question-Tracking-Multiple...)!
Hopefully though we should be able to figure this out and make sure that its solid enough for production.