Microflow for loop instead of Iterator

I have a field on screen in which if a user enters 2 then two records should be inserted in the table if user enters 1 then only one record. I have thought of checking the field in microflow and creating a list but then there is no for or while loop available inside the loop default is ListIterator Any suggestions how i can achieve this
3 answers

Create a microflow that accepts the object with the field that will hold the 1 or 2 value as user input (I'll name the object dataObject).

In the microflow the first action is to create a variable (named: counter) and set this variable to the value of the field (recordNumber) of the dataObject input parameter. So the value will be $dataObject/recordNumber.

Now add a merge activity and after this add the create object activity to create the record to be inserted in the table. 

After this action add a change variable action that sets the $counter to $counter-1.

Now add a split after this change variable action that checks if the counter is greater than 0 ($counter > 0) if true this will end the microflow. If false connect this to the merge activity added in the second step.

Now you have a manual for loop in your microflow and the only thing left is to trigger the microflow.

Hope this helps you in finding a solution.


I found an answer with a visual representation of how to achieve what Erwin described: