Looping Table Parent 1 and Child 123... [SOLVED]

Beautiful people, I need some super help :sos:

I’ve been trying to resolve this for a few days now and I need the help of a sympathetic soul.

I managed to solve most of it by watching advanced database classes.

The idea is as follows…

I have a parent table and a child table

Every time the child table id reaches 10, a new parent id must be received and the count restarted.

Would be like this

Parent id = 1 And child id = 1

Parent id = 1 And child id = 2

Parent id = 1 And child id = 3

…until child id = 10 Then

Parent id = 2 And child id = 1

… and so on

I tried using only when using conditions from the child table in every way, I even created a Boolean field to try to resolve it.

I think it might be something simple, but I can’t see it.

Complementing…

I have a list of parent ids that goes up to 4 thousand already registered in the parent table, when it reaches the last parent id it goes back to parent id 1 and the child id will start from 11 to 20 (but initially I want to complete this initial cycle, then I I can create another counter that starts from 11 to 20). I’m only using it in the backend workflow, on the front I just use a button to start the flow. And there is a counter table for the parent and another counter table for the child

what is the use case for this?

1 Like

Hi friend. It’s for creating surnames. Example, Father 1 Adan Rosa, Son 1 Adan Rosa Terres, Son 2 Adan Rosa Pereira until son number 10 then stops for father 2

Do you the list of fathers already created, and if so are they already stored in your database as a datatype?

1 Like

Hi master, yes, I already have a table in the database with all the parents registered, the children that do not yet exist will be created from the parent table.

What happens when I put the condition in the counter is that it cancels the action until the child is 10 then it starts a new parent, but only child 10 will receive the parent id, because only when cancels the operation instead of pausing , I would need a While action, While child from 1 to 10 so the parent is the same. I think I’ll have to see another way to solve it, I don’t think I can do it in the only when of the parent counter’s action

  • PROBLEM -

I looked in several places, I even opened a ticket on Bubble and nothing was resolved.

What happened?

As I didn’t know that the bubble completely canceled an action when you use an only when condition, I was looking for the last processed id of the previous step, which was the parent counter. So it always came empty because the action was canceled until it reached 10.

  • SOLUTION -

Simple, but it took me days to wake up.

Instead of searching in the previous step, I searched for the id directly in the parent counter table.

If it weren’t for you commenting here I wouldn’t have created the motivation to persist in searching for a solution. Receive my immense gratitude.

1 Like

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