Creating a number of things based on a quantifier (number)

Hello! It seems creating several things is a bit tricky in bubble.io. I need help as I am currently unaware of how to move forward with these. Just a point in the right direction, please.

I have a field that shows a number, like an order quantity. The things (number of things) are created depending on the quantity stated in that number field. I have read toolbox, API workflow, but I am still confused and would like to understand which is the best way forward for my use case.

Appreciate all the advices! Thank you!

The Simplest way to do this is by running an API workflow on a list of things.

Simply create an API workflow that creates 1 thing.

Then run that workflow on a list.

That can be any arbitrary list, of anything, with a count equal to the number entered in the input.

The simplest way to do it is using the Toolbox List of Numbers element.

Add the element on the page. Set the start number to 1, its increment to 1, and its length to the value of your number input.

Then, just schedule your API workflow to run on that list of numbers.

There are alternative ways (such as using a recursive workflow, which will be slower and more costly in WU, or using the data API which will be faster and less costly in WU), but for simplicity, I’d use the method outlined above.

2 Likes

Do you mean here to use Schedule API Workflow on a List?

List to run on - I am trying to use the element Input Quantity, but it is error:
Screenshot 2024-03-06 at 23.14.46

Blockquote

Yep…

No, as I said, you need to run it on the list you’ve generated with the List of Numbers element from the Toolbox plugin.

Does it automatically create a list when I input a value in the quantity field - meaning in the toolbox element?

Because when I simply input quantity is 5 - I noticed that there appears to be 5 items in the list

Yes, it does. So just use that as the list to run on.

@adamhholmes So this should run on element - ListofNumbers A - right?
Screenshot 2024-03-06 at 23.27.52
But the element ListofNumbers A (“Toolbox”), could not be found. I can only find the quantity input in which I connected the toolbox element.

Additionally, what should be in the API Workflow field, and the scheduled date?

My apologies for asking too many questions as I am abit quite lost here, but thank you for leading me to the toolbox/listofnumbers.

Screenshot 2024-03-06 at 23.28.17

Yes, it shoudl run on the ListofNumbers A’s List

But the element ListofNumbers A (“Toolbox”), could not be found.

It should be there on the list.

But there’s a persistant bug with Bubble in recent months, where things like this don’t always appear… so a workarounf id to create the expression somewhere else first, then copy and paste it.

If that doens’t work, then maybe your List of number Element is inside a RG? In which case that changes everything.

Additionally, what should be in the API Workflow field, and the scheduled date?

In the API workflow field you need to select the API workflow that you want to run.

And the date is the Date you want the workflow to run (which, presumably is NOW… i.e. Current Date/Time).

Thank you Adam for this huge effort to assist me. Greatly appreciated! :pray:

1 Like

@adamhholmes Hello Adam! Can this be done using customs states instaed of toolbox?
I was able to do that in another function, but using RGs and parent group data. Since the toolbox the scheduled API cannot find the list/toolbox element, I was wondering if this can successfully be implemented using customs state.

or perhaps there are other smarter ways to do this?

Any reason not to copy a list of things (and keep a list of things as placeholders for such use).

Hello, what do you mean? Is that another way to do the multiple creation of things? Sorry I am figuring out a way to do this properly.

I’m not really sure what you mean?.. The toolbox plugin is just used to generate a list of numbers.

Sure… you can use any list…

It’s just simpler and cheaper to use a list of numbers than to be pulling things from the database.

You can also use an arbitrary text, split into individual texts… but still the List of numbers form the toolbox plugin is the simplest way to create a list, in my opinion.

Thank you Adam. I think the recursive workflow allows me to achieve my desired results. Especially the quantity is not plenty each loop. @adamhholmes

Recursive workflows are another option… but they are considerably slower (by multiple times), and a lot more costly in WU.

But for small numbers of things, it’s probably not that big of a deal.

Thanks @adamhholmes for your detailled description, it really helped me forward.

Nevertheless I’m still struggling with this one.

My situation is slightly different (simple description, totally something else):
I’m modifying a “cart” with this “work on a list backend workflow” where I want to add certain “products”, these products are also things.
So in the cart database, I should end up with a list of products, based upon the number of products that are chosen from a dropdown.
This dropdown value is stored in a ListofNumbers as suggested and I’ve a backend workflow on a list running on the ListofNumbers for adding the product to the cart.

Where does it go wrong?
The product is added, but it’s only occurring 1 time if I choose any number. So if I pick 5 from the dropdown, it’s only added 1 time to the product list of the cart.
If I’m looking at the loggings, I see the action being started and ended 5 times, so you would expect that this goes well.
I don’t get it…

I can add several products in the App data of the cart by hand, so no issue here.