Create a number of new things based on the iteration of two combined lists


I am creating an app in which the user orders a service consisting of at least 1 (and up to 10 activities), each of which has 1 to n selectable variants (typically less than 10).

So, I created a wizard where the user first chooses the activities and sorts them:

Select task

Then he selects the variants (these not need to be sorted):

FLAVOUR selection

Finally, he clicks “Create Service” and Bubble creates the new service by performing the following operation in the Database:

Step 1

Now, HERE IS THE PROBLEM: I need Bubble to create as many sub-services in the database as the number of activities chosen, multiplied by the number of variants selected.
So, in the above case (where “3 Tasks” and “3 Flavours” were selected) I would need to have 9 (3*3) Sub-services.
Basically, in the database I should get this (note: the following table goes beyond the selection of 3 tasks X 3 flavors and assumes the selection of “n” tasks and “n” variants using grey color):

Step 2

Finally, at the end, another workflow adds the list of created Sub services to the Service - but this is not a problem for me.

I have carefully read many forum posts and watched several videos (n particular those by @keith, @petter, @NigelG, @romanmg, @boston85719, @cmarchan, @gaurav, @emmanuel and many valuable other bubblers), but I have not yet been able to find the right way forward.

I assume the solution is somewhere between “scheduling api workflow on a list” (on the backend) or iterating the list using the List shifter karmarawe plugin (on the frontend)…Both procedures are clear to me on one list, but I get lost because I am dealing with 2 lists, not one! Probably the solution is to create a single list by combining them, but I wouldn’t know how to do that since the 2 lists are composed of values that come from 2 different custom data types.

I would never stop thanking you if you would share what you consider to be the Best Practice to perform “step 2” described above.

Many thanks in advance :slight_smile:

Hey Renato,

This sounds like a job for recursive workflows. You may need to run it through a few cascading workflows to get the effect you want. Probably something like each cycle of Recursive Workflow 1 creates one Task, and schedules Recursive Workflow 2 to create the Flavours for that task.

I have an article on recursive workflows that you may find helpful. They are similar to running an API Workflow on a list, except it offers more flexibility. Also, contrary to Schedule on a list recursive workflows are actual loops while the former is basically just a list of scheduled workflows.

Hi @petter ,
first of all I want to thank you so much for the tip and apologize if I didn’t get back to you sooner: your suggestion seemed so enlightening and solving (actually I had read it a few months ago also in your book, but I wonder why it didn’t pop into my head sooner!) that I got to work right away, confident that I could come back after 5 minutes on the forum and write " Hurray, thank you, everything solved!"…And instead I was stuck to the PC for 1 whole day :neutral_face:

The main problem I couldn’t overcome was letting the “Recursive Workflow 2” know what had already been done by the “Recursive Workflow 1”. I think it is because I have not yet well learned how to use recursive workflows…If you have the time and patience, maybe you can correct me! :upside_down_face:

Anyway, the goal I needed to achieve becomes perhaps clearer if we put “Task and Flavour” apart - and we think of a Project management app which, to manage this:


Must create in database this:


With Recursive Workflows I was able to set up the “Create a new thing” action, creating “Thing #1 (Task 1 + Stage 1)” and then–recursively–create “Thing #2 (Task 1 + Stage 2)” and “Thing #3 (Task + 1 Stage 3)” and I could go on for any other “n” selected stages.

However, I could not find a way to set up “Recursive Workflow 2” so that it would go on to create Things #4, #5, #6, #7, #8, #9, #n without replicating all or part of the Things #1, #2, and #3 already created which pertained to Task 1.

To work it out, I had to use a mix of all the solutions on the field. Basically:

  1. The user clicks the “Create Service” button.

  2. The “Create Service” button triggers the “Schedule API workflow on a list” action, which uses the list of Tasks chosen by the user (can be 1 or n)

  3. The API Workflow that is launched has as Step 1 “Create a new thing” using [Task 1 passed from the list] and the [flavour:first item]

  4. This API Workflow is repeated recursively “n” times as many as there are flavours set by the user. At each step I reduce the list with the [:minus item - “step 1 Flavour”] operator with the condition that the action should be repeated until the list is > 0.
    So in this step I create Things #1 through #n consisting of [Task 1] + [Flavour 1, 2, 3, n]

  5. When the recursive workflow loops are finished, Bubble goes to the next Task in the list and launches the API Workflow again repeating it recursively as above until all Tasks (2, 3, n) are completed.

What do you think? Do you see any critical issues in the above solution?

Thanks again for your support - very much appreciated! :slight_smile:

This topic was automatically closed after 70 days. New replies are no longer allowed.