How to break a process from While loop

I have faced one scenario. I want to exit/break from a while loop based on a condition. But here i am not able to jump the loop.
Kindly share some suggestions.
@Palaniyappan @lakshman @Lahiru.Fernando

Thank you :slight_smile:

1 Like

Hi @Kalees9486

A While Loop/Do Loop, must have a condition to met. Try to do a If when you need to exit the loop which will give the condition to exit the loop.

https://go.uipath.com/component/while-loops-with-break-and-continue-activities

Regards,
Kommi Jeevan.

2 Likes

@Kalees9486,

If you are using while loop with a condition, when it meets, then make that True. So it will terminate the loop.

Try like this,

It goes littlebit long what i want.

Here my condition is starts from counter 1.keep on increasing right. if the amount, qty was null means i want to exit the loop.

Hi
Lets do one thing
–keep the while loop within a TRY block of TRY CATCH ACTIVITY
–then inside the while loop use a IF condition with any condition that you would like to have so that the while loop will be broken and come out of it
—so if the condition is true it will go to THEN apart where we can use THROW activity and mention a BusinessException like this
new BusinessException(“break while”)
So that it will get broken and goes to catch block where we can just mention a exception type like System.Exception and can mention with any activity or leave it as it is

Cheers @Kalees9486

3 Likes

Ok.i will try.
Can you suggest some other way.i want to extract line items from SAP screen.i tried with get text activity for each aand every columns.I want to loop it,because we need all the lineitem not only one.So how to start the loop for extracting lineitems?
If i use while activity i just write condition as counter > 0 as condition.But how to use for each activity instead of while? @Palaniyappan

1 Like

i didnt get this buddy
kindly elaborate a bit more on the process pls
Cheers @Kalees9486

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.