How to stop first for each loop in using nested for each loops by using break



Scenario:Using nested loop when i met my expected condition the first loop will Stop or End

Steps to reproduce: 1) Create a first for each loop

  1. Create second for each loop in First for each loop
  2. Create If Condition and if true then use break

Current Behavior: stop the second for each loop and executing the first loop

Expected Behavior: stop the Entire loop when my condition met

Studio/Robot/Orchestrator Version: community version

Last stable behavior:
Last stable version:
OS Version:
Others if Relevant: (workflow, logs, .net version, service pack, etc):


Hey @mytest1724_1724

There is no way of using break to break out of multiple loops. The break command will always just apply to the inner most loop.

You can do like this

Bool break_flag = False;

                  if(your condition ==true)
                    break_flag = true;
    if(break_flag== true)



Thank You aksh1yadav


I have issue breaking the first loop in a nested loop scenario. UIPath is not moving to next line of code after breaking of first loop and just get into wait.

loop 1
line of code
line of code
loop 2
line of code
loop2 exception handler
end loop2
exception handler loop1
break; comment: it is coming to this line of code but not breaking and moving to 'more line of code’
end loop1.
more lines of code.


This issue is under development, i don t have a timeframe for now.


Hi Venkat_Vuyyuru:

You can stop the first for each loop using an if statement after.

For example, if you arrive to the last part of your inner loop, you can assign a boolean variable a value of “True” (or "false if you want), so when the first for starts again, in the other part of the first if statement you put a “break”.

I hope to have been clear.