I am trying to create a feature where a user can add a grandparent record, and create parent records within that which contain a count of children, and then when the grandparent record is saved the child records get created for each parent. I apologize if that is too abstract. I have created an app which will create one child record for each parent, but it is not properly looping through the count of children to create more than one record for each parent. What am I doing wrong?
Here’s a sample app that I’ve created.
For further background: I consulted this video which was very helpful and from it I was able to create a simple “parent creates children” interaction, but I have struggled to get this to work with one more layer of hierarchy. In my current iteration I’m not actually using a Numbers table nor a virtual column as the video shows and as I did in my earlier iteration. Maybe that’s my problem? I never really understood why the Numbers table was necessary. Either way, the automation is not looping through the “child creation” process as I intended. I’m going to paste some gory details below, and thanks in advance to anyone who can point me in the right direction.
=======
This is how I created the sample app linked above:
Generalized grandparent, parent, child pass down
-
Create a table for Grandparents
- Grandparent id
-
Create a table for Parents
-
Parent id
-
Grandparent id
-
Count of children
-
-
Create a table for Children
-
Child id
-
Parent id
-
-
Add all of those tables to an Appsheet app
-
Set the Parent id column of the Children table to a ref of the Parents table
- Is part of? Yes
-
Set the Grandparent id column of the Parents table to a ref of the Grandparents table
- Is part of? Yes
-
Create an action in the parents table that creates a single new record in the Children table
-
Name: Create one new child
-
Data: add a new row to another table…
-
Add to: Children
-
Set columns Parent id to [_THISROW].[Parent id]
-
-
Create an action that decrements the Count of children in the Parents table
-
Name: Counter downer
-
Data: set the values of some columns in this row
-
Set these columns: Count of children = [Count of children]-1
-
-
Create an action which groups these two actions together called Grouped action to loop
- Behavior > Only if this condition is true = [Count of children]>0
-
Create an automation
-
Event: Adds to the Parents table
-
Condition: [Count of children]>0
-
Process: Run a data action, Grouped action to loop
-
Testing
-
Does saving the Grandparent record create parents? Yes
-
Does it create children with the right parent id? I think so?
-
Does it create the right number of children for each parent? No