How to create a Thing, multiple times?

My response in 2017 was flawed as I didn’t understand how to use “Schedule a List API”. Without going into too many details right now, this functionality absolutely exists and I probably should have amended my post - I’m on a personal plan and have the ability to create a thing multiple times and have been using it for months now.

In short:

  1. The 20 items for your “Chef’s Choice” need to be put into a list (maybe you could do a Custom State, Type Text, Check the “This has multiple entries”).
  2. Then, Schedule a Workflow on a List action. The list to work on is the Custom State you created in Step 1.
  3. You’ll then go to “API Workflows” in your pages menu.
  4. Inside of there, go to General → New API endpoint.
  5. In that new API endpoint, this is where you do your database magic - Adding the “thing” to your database.

Once run, the “Schedule a Workflow on a List” will take your Chef’s Choice list and for each one, run the actions inside of your API Endpoint which will include your database call to create a Thing. It will do that for all 20 of the items and then stop.

The fun part, as anyone will tell you, is how to let the user know the scheduler is running and creating your database items. I’ll let smarter folks take that one as it’s all over these forums.

Hope that helps.!

8 Likes

In other places it seems folks have let you know about how you can go about creating multiple items. But it seems like you could streamline this process a bit by rethinking how the “Chef’s Choice” works.

Clearly you have some sort of product/SKU datatype right (I’m going to call it SKU)? So, instead of thinking of “Chef’s Choice” as a concept, shouldn’t that be a SKU itself?

But it would be a SKU that is a “bundle”. So you might consider adding to your SKU datatype a boolean for “Bundle”. A SKU with bundle set to true would have a list on it of type (whatever type goes in your shopping cart - I’m gonna call them Order Items, OK?). Let’s call that field “Bundled Items” - again, it’s a list of type Order Item.

So, when you define a bundle SKU, you put prototype Order Items into that list. (Whatever it is that’s supposed to wind up in the cart, you make those items and put them in that list as part of the definition of this month’s or this week’s or just the current Chef’s Choice product.)

Then, the user just shops for Chef’s Choice like they do anything else. And you just add it to their shopping cart like any other product. Obviously, you need to make a small modification to your add to cart workflow(s):

If the added SKU’s Bundle is yes, that tells us there is a prototype list of Order Items that also should go in the shopping cart. Since we now have a list of those things right on the SKU, we can do action COPY A LIST OF THINGS (what type? Order Items. What list? SKU’s Bundled Items).

Now that workflow step holds a copy of 20 (or however many) shiny new Order Items that have been created. These have brand new unique IDs, etc. (Copy is like create new, but it makes a list of things. Hooray!)

Now, of course there are probably customizations that you need to do to these items. Let us say that your Order Item has a field on it for the Order itself or something. Obviously the “prototype” Order Items you stored on the Chef’s Choice SKU wouldn’t have these yet. But that’s no problem, because we can:

MAKE CHANGES TO LIST OF THINGS (What type? Order Items. What List? Results of the COPY step.) Change whatever fields you need to change.

NOW you have a list of Order Items that’s exactly like the User had manually added them to their cart. Nifty. This list is stored as the results of the Make Changes step.

Finally, we must take this list of Order Items and actually add it to the Shopping Cart or Order or whatever it is you are building.

Take that list and just “add list” to the Shopping cart’s list of Order Items. (That would be a Make Changes to a thing step. The Cart has a list of Order Items on it presumably. When you select that list as the filed to modify, you’ll see you have all these list-wise options instead of just “=”. The one you want is “add list” (that takes a list of things and adds it to an existing list).

Proceed with the rest of your workflow as normal.

1 Like

BTW, the various advantages of this are obvious: All of this can be done without explicit recursion (listwise actions like I’m talking about use recursion, but it’s built in and you don’t have to manage it yourself). Also, now you know from the orders that the customer selected Chef’s Choice (How many people use Chef’s Choice? Well, just do a search for orders that include that SKU right?) You could offer discounted prices on the Chef’s Choice items easily (because they could have custom SKUs themselves on them). Etc., etc., etc.

1 Like

That’s awesome! Thank you so much for taking the time to write that out @keith! I really appreciate it! Going to try now.

1 Like

Note that I made a bunch of assumptions about how your current flow works, but based on what I’m describing you should be able to make this idea work regardless.

1 Like

I’m dealing with this problem right now. I know I can solve it using a Backend Workflow but it would be nice if Bubble added this functionality in the future.

The original post in this thread is very old. If you really need an iterative workflow, you can use my List Shifter plugin for that.

Recap of how to iterate using List Shifter:

1 Like