How to use break statement in for each loop?

Hi, I am using for each loop to iterate a logic. Inside, I have a script which checks multiple conditions at the same time. My question is: can we use the break statement to get out of the foreach loop when a condition is met in the script. And how to do it?

Hi @jana_kiran1991 do you need to stop the loop and not perform any actions for the element that meets a specific condition and go on to the next element?
Or do want to spot the For Each loop altogether and skip all other elements once some element meets a specific condition?

Hi @jana_kiran1991,

Please find the sample script for break statement, which can be used inside CustomAction Script as well,

Hope this helps :slight_smile:

1 Like