How to set condition to capture result for all items in list before run to next step


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? 

 


4 replies

Userlevel 5
Badge +14

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 
A 1 Y Y
A 2 Y Y
B 3 Y N
B 4 N N

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. 

Userlevel 5
Badge +14

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. 

See: https://youtu.be/-Wv7w9tKQ2I 


(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: 


 



  1. Item A-1 is now Complete, and checks to see if Item A-2 is also Complete.

  2. Item A-2 is NOT Complete, so the workflow on Item A-1 stops without doing anything else.

  3. Item A-2 FINALLY Completes, and checks to see if Item A-1 is also Complete. 

  4. Item A-1 is ALSO Complete, and so now Item A-2's workflow will do some FINAL Action.


 


While that method *can* work in certain scenarios, there is always the risk that the following happens:


 



  1. Item A-1 is now Complete, and checks to see if Item A-2 is also Complete.

  2. Item A-2 IS Complete, but did so just before A-1 checked it

  3. Item A-1 will do some FINAL Action.

  4. Item A-2 checks to see if Item A-1 is also Complete.

  5. Item A-2 will do some FINAL Action.


 


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


 



  1. Are these Batched Items related to a single Parent Item?

  2. What happens after all of the Batched Items have reached the desired state? 


 


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-Item-States/td-p/67264)!


 


Hopefully though we should be able to figure this out and make sure that its solid enough for production. 

Thanks for the great advise! I will try to figure it out and will keep you updates.

Below are answers for your question:
1. Are these Batched Items related to a single Parent Item?
- Each item will receive confirmation from different person.
2. What happens after all of the Batched Items have reached the desired state?
- Let's say all items in Batch were confirmed, 'Ready to proceed' column will change to 'Yes' once the last
item in particular batch confirmed, then email will send out to person responsible for next step to
perform their task for each batch (ideally one email per batch).

Reply