Create a child record from the parent
This guide demonstrates how to create a child record, from the parent record. These instructions should work with a SQL connection or the Budibase Internal DB.
In this example, we have a “Customer” record, with “Notes” attached to it. One Customer has many notes.
We will build a screen that
  1. 1.
    Lists all notes for a customer.
  2. 2.
    Has a “Create Note” button, which allows a new note to be added via a modal
  3. 3.
    Refreshes the notes list when the modal closes.
You can import my full example app to see exactly how it’s done:
Starting with a standard “Customer Detail” screen will first add the list of notes belonging to that customer:
  1. 1.
    Add a new Data Provider, inside the Repeater.
  2. 2.
    Set the Data property to “Repeater.Customer.Notes”. This will depend on your table and column names - i.e. “Repeater.Parent Table.Relationship Column”.
  3. 3.
    Add a table to your data provider.
Next, we will build our “New Notes” modal - our child record.
  1. 1.
    Add a new screen.
  2. 2.
    Set the URL to /notes/new/row/:customerid
  3. 3.
    Choose “Notes - Detail”.
  4. 4.
    Click on the “Save” buttons, and “Define Action”.
  5. 5.
    Remove the final action for “Navigate to”.
  6. 6.
    Add an action for “Close Modal”.
  7. 7.
    Click on the “Save Row” action.
  8. 8.
    Click “Add Column”, and choose the “Customer” column (the parent record).
  9. 9.
    For its value, use {{ URL.customerid }} - this links to the parent customer, via the :customerid URL parameter.
Finally, we will add a button that will open our screen in a modal.
  1. 1.
    Create a new button, and position it.
  2. 2.
    Click on the “Define Actions” setting.
  3. 3.
    Add the action “Navigate To”.
  4. 4.
    Set the URL to your “New child” screen. You will need to pass the Parent Record’s ID into the URL. For me, It’s “/notes/new/row/{{ Repeater.Customer._id }}”. If you are using SQL, use your parent table’s primary key.
Now - test your app!
Last modified 1mo ago
Export as PDF
Copy link