A new record in a table triggers a new record in another table?

Hi all,

I am trying to get these new records functionalities to work.
I would like to use an example to make my question easier to explain.
Let’s say I have two tables:

  • Food Orders
    | ID | Food | Customer |
  • Food Delivery
    | ID | Food | Customer | Status |
    When a food order comes in, I am going to insert a new record to “Food Orders” table.
    Let’s say “Food” field is set to “Fried Chicken”, and “Customer” is set to “John Doe”
    This new record will need to trigger a new record to “Food Delivery” table with field values that were inserted in “Food Orders” table.
    So “Food” will also have “Fried Chicken”, “Customer” will also have “John Doe”, and “Status” will be just set to a default value “Pending”

How do I do this in tadabase?
I have explored the record rules, page rules, and pipes but I couldn’t find the solution.

Thank you,

Handi

Hi, my suggestion is to create the first record using a form, and to create some record rules in the form to push the form data to save a new record (insert a connected record option) in the second table; you can take the field values from the first table to populate the new record of the second table

Welcome to Tadabase. You can do on the backend through Tasks but depending on what you are doing it may be better to do it through the form entry as Aprada suggested.

To do it in the backend. You must have a connection field in the Food Delivery table to Food Orders then →

  • Tasks > Add new task
  • General tab > choose Food orders table > set trigger to On Demand
  • Action tab > action = insert a connected record > Select connected data-table = Food Delivery
  • Set Values as shown in picture below.

Note though in this particular example I would not recommend this. I would do 1 table with a select field for delivery status. Or in a more complex version I would use parent/child connections.

Thank you @Aprada and @ChTim !
I did it based on Aprada’s suggestion.
@ChTim, I am curious what would be a good use case by doing the Task solution?

One reason I use tasks is actually to update records manually when I am testing something in a build. I just trigger it manually then connection records et al get updated.

A few reasons I can think of:

  • Trigger webhooks based on certain conditions - you could also do this through a pipe in table rules or other spots.
    *You can use tasks to close out and send invoices at the end of the day.
    *Send a daily, weekly, or monthly report(s).
    *Clean out data every X days if there were temporary records you didn’t need/want to keep long term.

I’m sure others could list a lot more reasons. Currently I’m not using a lot of tasks myself.

Thanks @ChTim !

got a slight feeling that youve encountered one of the most classic challenges in tables design… many to many relationship.

you need food menu (item, description, price) standalone table.
plus at least 3 tables - customer table (users), Orders table and Order line items table. Add Action button to form to insert new record into OrderLineitems tablr