I stubbornly wasted quite some time trying to get around this instead of asking for help. When I finally asked for help the solution was clear within minutes.
I’m writing this as a:
- note-to-self (I tend to forget),
- way of helping someone else in the future; and,
- getting some feedback from the Bubble hive-mind.
Here is the solution I came up.
tl;dr learn how to use recursive workflows.
Some context: I need to:
create a list of Apartments within Buildings (100-300 apartments per building, up to 30 buildings), and
add those created Apartments to the Building’s List of Apartments.
It’s a poor-man’s graph database, I guess. The problem was that I would schedule an API workflow on a list and, because of well-documented limitations of Bubble’s database, these items would either not be created at all or they would not be added to the Building’s List of Apartments.
The main problem was that it was trying to add multiple Apartments to one Building’s List of Apartments. That lead to data inconsistencies.
The solution I came up with - with the tutelage of the all-knowing @romanmg - was to create a recursive workflow for each Building. So that only 1 Apartment is added to the Building per iteration.
When the user clicks a button, it schedules an API workflow on a list; running on a list of Buildings and I pass a
list with texts that will be used to create the Apartments.
- that API Workflow creates an Apartment
- then adds it to the Building
schedules itself again, but this time it takes that
list of texts:minus list of texts:first item (which was the item just used).
- it will stop scheduling itself when that
list of texts:count is 0
This is probably child’s play for you pros, but for me it was like the first time I discovered VLOOKUP in Excel.
I hope this helps some poor soul in the future.