Insert Record - Table Parent + Child

I want display one form and one table
Form for insert parent record
table for insert children records with same id

I think you should just follow what I described in my first reply :slight_smile:

ok, but i need master/detail one page
is it possible ?

It does not matter if it is on one page or not.
You do this in one server action with two insert steps.

ok, I have this but it doesn’t workCattura

Can you explain what is not working? Are there any errors or?
Maybe it’s worth checking this and see what your server returns: Debugging Problems

I do not understand how I can create the master / details mask to insert the data. I can only create the master part

Yes it is possible.

  1. Your page shows a query from the database
  2. The query can be clicked to show details

Now you want to insert to 2 tables at the same time

  1. Make one server action
  2. Add Database connection
  3. Add Database insert to erp_db.documenti (name it insert_master)
  4. Add Database insert to erp_db.righe_documenti (name it insert_details)
    for the column id_documento go to the value area, click the lightening bolt icon, in the list of available bindings you will see Database Insert: insert_master, arrow it out, you will have 2 bindings identity is what you need to select.
    Now the column of id_documento will have a value of {{insert_master.identity}}

Maybe that makes more sense.

1 Like

ok, it works
it has correctly entered the data in the database
now I would like to have one form + one table on the page
the form for insert_master and the table for insert_details
how can I do?

Your insert step is a single insert into master and detail at the same time so on your page you are just going to have 1 form with a whole bunch of inputs inside it.

Make a container on your page with a row inside it, with a column inside that, then tell it to add inside that a Bpptstrap 4 Form Generator from the Generators category, then select the server action of inserimento_documento_vendita and do not use the Populate area, this will then bring in all the fields you will need to use the insert server action you just created.

ok, so I have to manually create the various input boxes and the details table

No, if you follow my instructions, when you click the Bootstrap 4 Form Generator it will automatically pull in all the inputs it needs according to your insert record server action.

Assuming that the details is of a multi type, then you need to have an extra step between insert master and insert details, namely

image

Hi @ben, as far as I know he is not trying to do a multi insert, he is just trying to insert a single record inside two different database tables. The Server Connect portion of his insert is now working as he wanted, now he is wanting to add a form onto the page which will be used to enter the data. I have suggested he use the Bootstrap 4 Form Generator to add the inputs required.

Awaiting his response to see if everything worked as expected.

1 Like

For as far as my Italian goes he is talking about a product category list and related products as detail region. Where he wants to be able to insert several related products to one category.

exactly
sorry for my bad english
I will study again

Guys, are you referring to actually inserting database records or just display records on the page?

inserting my records

Ok, it’s not really clear what you need to achieve.
Can you try with a few simple sentences and maybe some screenshots to just explain what needs to be on your page and what needs to be inserted in your database?

Number Document 1 (Master+Details)

Number Document 2 (Master+Details)

I hope I explained myself, I have to save the invoices in the database