Page 1 of 1

Create Multiple Records in a Table from one form

Posted: 2020-10-13 17:02
by walter
I am wanting to create a bidding application which is similar to the northwind orders demo but instead of orders of products it will be a pre-order bid or estimate of products and labor. I know how to create one record at a time in the data collection form, but is there a way to add multiple records from one form?

An example is I add a size of electrical conduit to to the bid, but before i submit the form i would also like to specify how many conductors of a certain size are in the conduit. Once saved i would have two line items in my estimates table. The first line for the conduit with price and labor columns attached. The second line with the conductors with price per ft and labor attached.

Is there a way to do that in appgini?

Re: Create Multiple Records in a Table from one form

Posted: 2020-10-13 17:19
by pbottcher
Hi,

yes, you can do that in the after_insert hook. Create your sql statement to insert the record in the table an call the sql/sqlvalue function to execute it.

Re: Create Multiple Records in a Table from one form

Posted: 2020-10-14 16:24
by walter
pböttcher,

Thanks for the reply. I am not sure how that is done, but maybe by watching Ahmed's Udemy course along with your reply, I will be able to figure it out.... hopefully...

Re: Create Multiple Records in a Table from one form

Posted: 2021-09-22 12:45
by sacgtdev
Interested to know the method.

Re: Create Multiple Records in a Table from one form

Posted: 2021-09-28 15:53
by onoehring
Hi,

as pbötcher wrote:
use the /hooks/tablename.php -> after_update function to
a) read the entry from the database that has just been created. For this you use the $Selected_ID variable that AG provides in that function. Something like this (pseudo code):

Code: Select all

$record = sql("select * from yourtable where pkfield = " . $selected_id;
b) write the entry again (maybe including some changes)


Olaf