Create Multiple Records in a Table from one form

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
walter
Posts: 2
Joined: 2020-09-17 13:48

Create Multiple Records in a Table from one form

Post by walter » 2020-10-13 17:02

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?

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Create Multiple Records in a Table from one form

Post by pbottcher » 2020-10-13 17:19

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.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

walter
Posts: 2
Joined: 2020-09-17 13:48

Re: Create Multiple Records in a Table from one form

Post by walter » 2020-10-14 16:24

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...

sacgtdev
Veteran Member
Posts: 75
Joined: 2020-06-10 11:14

Re: Create Multiple Records in a Table from one form

Post by sacgtdev » 2021-09-22 12:45

Interested to know the method.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Create Multiple Records in a Table from one form

Post by onoehring » 2021-09-28 15:53

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

Post Reply