While Loop

Dear Mendix Community, I have an Object containing the Attribute “runs” determining the actual number of runs. If the number runs is 5, then Mendix is supposed to create 5x new Object and create a relation between the current object and the created one.   While using Loop, however I realised that the Loop is only able to iterate over an existing List.   Do you have any resolution for this issue.   Kind regards, Adam  
1 answers

The solution would be to define a variable (lets call it COUNTER) with type Integer that keeps count of the number of iterations (starts with 0).


then add a decision split to see if the variable < (less than) runs.

if it is then do what is supposed to be done in the loop and then INCREMENTCOUNTER by one [make sure the increment is done otherwise you’ll be in an infinite loop)

if NOT then you have looped the necessary amount of times and so proceed with your code. 


This is an IMGUR link for the referenced mendix microflow: https://imgur.com/Tmglqs4