How to create multiple records from 2 related tables in 2 other tables

Hello everbody,

I’m racking my brains around a little problem.

I have 2 tables with about ten records (1 “master” table and 1 “detail” table which is linked to the “master” by a common object).

Table “master”:
Phase_name(text)
Description_Phase (text)

“Detail” table:
phase_name (phase_name object from master table)
Task_name (text)
task_info (text)
date_exec (date)

In the app, I would like to copy all of these 2 tables into 2 other tables which will have an additional “company” attribute.
This to generate per company, a “model” of phases and tasks.
Each company will have in a “library” a first type of phase and task by default.

I know that we can create a list of thing based on another table by a backend workflow but how to copy the 2 tables (“master” and “detail”) so that the link is not lost between master and detail .

In other words, how can I be sure to create the “phase” link of the “detail” file with the new “phase” that I previously generated in the “master” file.
In SQL, I do this in 2 seconds by 2 nested loops but in bubble, mystery…

Has anyone solved this kind of issue before?
A big thank-you.

Yes, this is straight-forward in Bubble. You are going to want to look at “Backend Workflows” and “Schedule API Workflow on a List”. We do this with something that looks like this:

Thank you for your reply.
If I well understand in your example, you create several chapters in a new table but based on a new course that you have previously created.
So the relationship is : one course and many chapters.

If I use your example, my concern is to create all the courses I have in a table and all the chapters linked to the course in another table (the link in the chapter table with the course in an object “course”).

To do this, I have to list all the courses, create a new record for each course in a new table and create one or several chapters in another new table according to the number of chapters I have.
It’s also a relationship “one to many”.

But how to recreate the link between courses and chapters in these new tables when the old links between the original tables will no longer work since they were created with the ids of the original table.
The goal is to find in the new tables created (courses and chapters) the links between them.
I hope my explanations are clear enough in English :slight_smile:

We do exactly what you described and we do it for a number of data types, not just chapters / courses. We store “master” records and those records are used to create templates for new companies that are created in the app.

It works using multiple steps which reference previous steps. Here is a larger idea of the concept.

Try it out and you’ll see it works.

Steps in workflow:

  1. Create a new company
  2. Schedule API on a list (All “master” records)
  3. Inside of scheduled workflow (the one you scheduled on step #2)
    3a. Create new “master” record
    3b. Schedule API on a list (All “detail” records that match the reference data type on the “master” record)
  4. Inside of the workflow you scheduled on step #4b - Create a new “detail” record

The process you describe works well, thank you!

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