I have personally struggled with this one. You have to get creative to create a list of things since bubble does not allow to do that in the same way that you can make changes to or delete a list of things
The way that I’ve solved this issue is firstly by doing it in the backend workflow, and secondly to have a list of anything (could be things related to it or could be a list of text, really anything). This list of whatever has to be equal to the amount of things you want to create
You need a backend workflow where you pass all the info you need to create your stuff and list of whatever, then have the workflow steps create your coupons. When your user reaches the step where they add the quantity and then go to the next step, schedule this API workflow for current date/time
This is how your backend workflow should look like:
-Schedule it with two fields, one for the current user and one for the List of whatever
-First step use the List Popper and Friend plugin, the List Popper SSA workflow step. in this step you will feed your list of whatever which will work as a way to tell how many iterations youll run the backend workflow.
-Second step is Create a new Coupon and generate the random string, the current date time and use the user that you pass to the workflow-s user field.
-Third step is Schedule API workflow. Only when Step 1’s List Popper SSA’s Remaining List Count is not 0. and feed into it the same User in the Workflow’s User field and to the List of Whatever field feed the List Popper’s Remaining List
This will run as many times as your user selected and when it finishes running for that many times, it will cease to reschedule
Creating a list of whatever is tricky though, specially if you’re going to allow for large numbers in the Quantity field.
This is what I do generally.
Lets say the user selected a quantity of 5
You do a search for whatever thing in your DB and use :items until # 5 (input quantity value for dynamic list) and have that list of items be passed down to the schedule api workflow as your list of whatever.
Keep in mind that you’re not actually going to use that list for nothing, you’re not modifying that list. You’re just going to use it to run your API workflow for as many times as you actually need using the list popper and friends plugin
What the plugin does is that it takes the list and outputs two states. One is the first item of the list and the other is the remaining list. So each time you run the workflow it subtracts one item from the list. If you use the “Remaining list” from the plugin to reschedule the workflow, it will reschedule itself for as many items are in the list. Each time it runs it will take one out of the list and feed the remaining list to the next iteration until it reaches 0. When the remaining list is 0, it will not run the iteration again.
Im sure there must be other ways to work through this but this has help me a lot.
Hope it helps!