Prepopulate parent reference based on previous interactions

Hi,

I have two tables Parent and Child. When users click on a parent element in my view, they see a list of related children. From here, they can add new children directly. However, the reference to the parent in the new child creation form is empty and users have to manually select the correct parent.

How do I get AppSheet to prepopulate the parent reference when creating a child from within a parent's view? When I was using an AppSheet database this was the default behavior, but, after switching to a Google Sheet backend, it isn't. Thanks!

Thank you!

Solved Solved
0 3 220
  • UX
1 ACCEPTED SOLUTION


@maurice123 wrote:

When I was using an AppSheet database this was the default behavior, but, after switching to a Google Sheet backend, it isn't


Huh?  This is an app function.  It wouldn't make sense that it works with the AppSheet Database and not with a Google Sheet.

Anyway, this has been a long-standing issue that dates back to pre-Google.  It requires a work-around and there are a couple of ways you can handle it.

1)  Force the user to add Children from the Parent Form and not from the Detail view.   If you have Parent calculations dependent on new children being added, this is the best way to go.  The big issue here is how to disable the Add button?  The way to do it is by creating a Slice of the Child table and setting it to Read Only.  In the Parent table create a NEW second Virtual Column based on this Slice - simply mimic the original "related children" column and swap the table for the Slice.  Then adjust your Parent Form to show the new Child Virtual Column that is read-only.  

2)  Add a custom action to the Parent Detail view to "Add Child".  In this action you can specify the LINKTOFORM() function and pre-populated any fields you wish onto the Child Form.  You can then display this action as Primary or Prominent.  You still need to apply the Slice option above to remove the normal Add button from the Inline table.

I hope this helps!

View solution in original post

3 REPLIES 3


@maurice123 wrote:

When I was using an AppSheet database this was the default behavior, but, after switching to a Google Sheet backend, it isn't


Huh?  This is an app function.  It wouldn't make sense that it works with the AppSheet Database and not with a Google Sheet.

Anyway, this has been a long-standing issue that dates back to pre-Google.  It requires a work-around and there are a couple of ways you can handle it.

1)  Force the user to add Children from the Parent Form and not from the Detail view.   If you have Parent calculations dependent on new children being added, this is the best way to go.  The big issue here is how to disable the Add button?  The way to do it is by creating a Slice of the Child table and setting it to Read Only.  In the Parent table create a NEW second Virtual Column based on this Slice - simply mimic the original "related children" column and swap the table for the Slice.  Then adjust your Parent Form to show the new Child Virtual Column that is read-only.  

2)  Add a custom action to the Parent Detail view to "Add Child".  In this action you can specify the LINKTOFORM() function and pre-populated any fields you wish onto the Child Form.  You can then display this action as Primary or Prominent.  You still need to apply the Slice option above to remove the normal Add button from the Inline table.

I hope this helps!

Thanks for the helpful workarounds! I implemented the button, but then by accident figured out why AppSheet wasn't prepopulating the fields correctly: The column name of the referencing (ref) field was not identical to the name of the key column in the referenced table.

Oh wow!  You are right!  I had a brain hiccup!

Adding a child from the Parent Detail view Inline view DOES pre-populate the Parent ID and it always has.  I was so influenced by your issue, I confused  this problem in another function - Child as a REF column.

There are times when you want to treat a REF as a Child rather than have a LIST.  Even though you might setup the Parent/Child relationship, when you tap NEW in the REF dropdown, the Parent ID will not pre-populate into the Child Form.  You either need to force entry in another less than desirable way or add the details after Save.

Top Labels in this Space