Hey @SenorPelota, (also @vini_brito): I had thought that @vini_brito’s link would lead to the documentation for the bulk create feature of the data API. Instead, he links to “schedule API workflow on a list”. I’m not sure why he does that as it doesn’t really answer your question.
Sure, if you can construct a list of “n” length, you can fire off an API Workflow on a List and, inside of that workflow, Create a New Thing of some custom type. (The arbitrary list of length n acts as a “for each” sort of loop.) And, ultimately, you will have created n new things.
While we have a bulk create (note its limitations) feature in the data API and can multiply create items in the way I describe above, this still seems rather strange. (And, you will also note that not only is there no “Create Multiple New Things / Create a List of New Things” sort of action, there are also no “Create List of Primitive Data Type” workflow operations.)
Before I go on to muse about why this might be. Let me provide a couple of “workarounds” for creation of multiple new things:
- Though there is not an action that will create a list of new “default” Things, you CAN “Copy a List of Things”. Consult the Reference for details on the limitations of this (the list can only be as long as 100 things). Again, this seems strange as it probably takes more cycles to copy a Thing and all of its field values than it would to create a new default Thing. (Test this, but I believe that the copied items get created in the Current User context and Current User becomes the new Things’ Creator.)
So lets say you have a Thing called Car in your database and you wanted to instantiate 10 new Cars in a single workflow, you could “Copy a List of Things” where the source is Do a Search for… Cars (with NO constraints and NO SORTING):items until #10. This will just grab the first 10 Car objects that can be found, copy them, and return them in a list.
You could then as a next step use “Make Changes to a List of Things” (source: the list returned by Step 1) to set their fields to some default values or whatnot. (If you need to change each individually, you might use Schedule API Workflow on a List to make whatever changes are needed.)
As noted before, you could ping your own bulk create API (see the Reference link noted earlier – this is on the GET/data side of the API). You can in fact do this in the API Connector (call your app’s own API endpoints) and I show an example and talk about this strange idea (which totally works, BTW) in my video about the Amazon Product API (search @keith Amazon product API should turn that up for you).
I feel like #1 is your best bet and note that you could manually create a “template” list of things that you want to bulk create in your database and attach them to some other object and just retrieve THAT list as the Copy source.
SO, BACK TO THE ISSUE of why it might be that this is so hard.
Note that, even beyond the fact that “Create New Thing (List)” is missing (such a feature would allow us to create n new things of a given type), you can’t even create an arbitrary list of primitives (make a list of numbers 1 thru 10, for example, or make a list of 7 texts) via a workflow action.
As Bubble has all the makings of a true “array-oriented language” (and I’ve always seen it this way), the fact that there’s no facility for creating such arbitrary lists seems like a very strange oversight.
I think the REASON Bubble lacks these facilities goes back to the earlier versions of Bubble where iteration was very, very, very frowned upon. And it could be that such functions (especially creating lots of new Things all at once, which is very database intensive) may have been seen as potentially dangerous to shared server stability.
Over time, Bubble has relaxed restrictions against iteration on the server (for example Schedule API Workflow is a form of iteration, recursive API workflows are a form of this, and most recently we have gained access to the server-side actions API, which enables the creation of arbitrary lists of primitive data types – though it does not let us perform Create or Make Changes operations on the database).
Some of the server side actions that I’ve been working on do just this type of thing. (Give me a list of numbers, give me a list of dates, generate a list of texts (like uuids), etc.) … And this makes Bubble a bit more like an array-oriented language as one now has things that one can usefully iterate over without looping.
The downside at present is that such operations are pretty slow. Part of this may be due to bugs/optimizations that Bubble is still working on for SSAs. But part of it is simply due to Bubble’s conservative allocation of CPU time. At the moment, I’m not sure how fast such simple actions might ever be. Returning a list of 10 created primitives is quick-ish. A hundred slightly less so. And then, each order of magnitude beyond that puts you very much in non-real-time territory.
Just some observations on this issue! Super good question, @SenorPelota!