I am creating a Master Record with many Children (normalizing the database). I am using a MariaDB. All relationships have been created (foreign keys). The master record has a primary key that is auto-incremented.
The form is designed with many accordions. Each accordion component updates a separate table that uses the Primary Key of the Master table. I know that I will need to create a succession of insert statements, one for each table I am updating.
In Wappler, how and where would I grab the Primary Key from the initial insert (after the DB assigns the auto-incremented value) and grab it to be used in the subsequent inserts (into the children tables)?
Yes, Jon. I believe there is a command and Syntax to add in some Wappler field to accomplish this. I just don’t know where it is to be placed and what the command would be.
Not sure if this advice will help, as it depends on how exactly it is all set up for you in Wappler.
If you have a server action file, say with 2 steps, and INSERT and then another INSERT or UPDATE, you can see in this screenshot below how you would use the PK auto-generated from the first insert to use in the update or insert of the 2nd step (by clicking the lightning bolt in the Value column):