Hi, I'm having trouble with create a normal loop, OutSystems provides a For Each loop but it requires a record list to use but I don't really need it.
My job is create a list with n (n is a dynamic integer) items. I want to create a loop to iterate from 0 to n -1 then I can do a ListInsert(). Please help.
Hi Long!You could use an If widget with the condition of a variable used as a counter (for example: Counter <= n-1). One branch contains the loop logic that goes back to the If widget, the other branch continues into the rest of the server/screen action. Set an assign before that If widget so that you can set the Counter to an initial value.Kind regards,Joseph Enriquez
Joseph Enriquez wrote:
Brilliant, why I can't think of If widget. Thanks for your support.
Hi Long,
As shown on the example below you could use an if widget with a count variable to create a loop.
Use an assign to reset the counter to 0 at every start then check your counter against Input (n) to loop through the inserts until the counter has reached Input (n).
Hope this helps!
Thanks! It helped me too. This "if loop flow" works like a 'while' statement. Simple, oldschool, but yet powerful.
Thanks! I am doing a store app, where customers add items to their cart and then all those items are to be deleted and added as order items, thus this is very helpful. for each was not helping me achieve my goal, thank you very much.