I have a ‘do while’ loop in which there is an ‘if’ condition that checks if the current time (Now) is greater than a maximum threshold limit. If this condition is met, it will throw an exception. I’m using this construct in various parts of my process. However, I’ve encountered a scenario where I don’t want to use ‘throw’ anymore; instead, I need to ‘break’ out of the loop. Based on my previous research, it seems that ‘break’ can only be used with ‘for each’ loops, and not with ‘do while’ or ‘while’ loops.
Can anyone suggest a way to exit the loop when Now exceeds 5 minutes (stored in the ‘MaxThresholdLimit’ variable)?
Do I need to incorporate the threshold condition within the ‘do while’ loop itself? If so, is the following condition correct?
(not ErrorsToolbarExist and WariningToolBarExist) or Now < ThresholdLimit
In this condition, I’ve reversed the logic from my initial ‘if’ condition, considering that the ‘do while’ loop continues as long as the condition is true. However, I’m still a bit confused. Is this the correct approach, or should it be like this?
(not ErrorsToolbarExist and WariningToolBarExist) or Now > ThresholdLimit
Alright, that’s interesting What Studio version are you using? And can you check if upgrading the UiPath.System.Activities helps, as I see you are using a preview version?
No i dont want to upgrade it , i dont want to mess things up right no , if upgrading causse any problems with my already existing activties in place, i dont have the time to rebuild the process , is there any other solution , as shown in the question above
we understood so far but would also recommend for the next projects not to use preview packages.
From your above screenshot, we have some doubts on the surrounding parts
we can rewrite (as same we did in older days) and will take control within the loop condition. Using variable for the loop condition did help for the implementation
If you don’t want to change package versions (there should be little risk though, if you just backup your project) there is an alternative:
In your do while loop, just create the condition b_Complete = false and in your if-validation set b_Complete = true
Depending on your actual process this might require a little bit of nesting of if/else blocks, if after where you’d normally place a break would be a lot of executing code, but it is at least an option to bypass the bug in the break activity.
Or… bit more dirty but definitely feasible:
Place the loop in a try catch, and throw a specific error instead of the break. Catch that error and consider it a non-errored exit of your loop.