Button to add a new child row related to current parent

Hi,

I'm trying to create a button in the parent view to add a new child referencing the current parent.

For example :

I have a "Project" table as parent and a "Comment" table as child. When navigating through the details of a project, I would like to be able to add a comment and automatically set the current project as the reference.


Could you please help me with this newbie question?

Thanks and have a nice day !

Solved Solved
0 6 1,622
1 ACCEPTED SOLUTION

6 REPLIES 6

By default, when you have a related records column and you show it in the view, appsheet displays the related child records as a table within the parent.  That table usually includes view and add buttons.  The add button will create a new related child record.

If you want to manually create an action button that will create a related child, you can create a new action for the table.  Set the action type to "Add a new row to another table" and configure the key field of your parent table to be the related parent record field in the new row.  

Thanks ! How can I configure automatically the parent key as ref using action ?

If your parent table has a โ€œrelated childโ€ column, make sure it is visible
in the view. If it does not, create the virtual column. It will use the
ref_rows function to define the list of child records. Once you have such
a column, adding it to a view of the parent record should give you what you
need.

Thanks, but I wish to manually create an action button. I set the action to "Add a new row to another table", but I can't define the ref row.

Even the way you describe doesn't work, because the reference is not automatically set. That strange, because the ref seems to be set automatically, but nothing is written in the ref column if I don't confirm it manually.

Edit : the ref column was set to "Not editable", so it wasn't show in dropdown menu when I choose "Add a new row to another table" as action. The problem is that column should not be editable by user once it has been automatically set. So I added this expression : ISBLANK([_THIS])

Only one thing is missing now. The button create de new row and set the ref automatically, but the new record doesn't open. Should I use another action to open the form ? It works with the "Add" Button generated by Appsheet. I'm trying to get the same behavior with my custom button.

Oh right, to immediately open the form, a different action is required.  Use the โ€œGo to another view in this appโ€ action, and use the linktoform function to create the child record. The function uses parameters to pre populate the parent id.   
https://support.google.com/appsheet/answer/10106538?hl=en

Top Labels in this Space