Tips & Tricks - Parameters - Save Parent Record with Child Records
This post shows how you can create and save any number of child records at the same time as creating a new record. Here you'll find a ZIP file containing a sample app that you can import into a portal as usual.
Sample Web Application
If the sample application is open in the browser, you can create a new parent record on the "Overview" home page by clicking "New."
In the tooltip below, you can now enter data for the parent record in the input field. Clicking "Add Child Record" displays another input field where you can enter data. By clicking "Add Child Record," you can display any number of input fields and thus create any number of child records. Clicking "OK" saves all child records as well as the corresponding parent record. The 1:n relationship between parent and child records is established automatically.
On the overview page, you can view the child records by clicking the magnifying glass button to the left of the ID.
Structure of the Sample Application
To create a parent record along with any number of child records, the prerequisites described below must be met.
Primary key of the parent data group with the data type "GUID"
The primary key of the parent data group must be of the "GUID" data type.
Input Page Parameters
The setting "Parameter is used only for existing records" must be disabled for the STRID parameter on the parent record entry page.
The "uniqueGuid" fallback value, which was newly created for the "STRID" parameter, is required to generate a new GUID.
Additional binding in the WriteContainer of the parent data group
For the parent record's Writecontainer, a binding must be configured for the record. To do this, select "Parameter" as the source, "STRID" as the parameter, and the primary key as the target.
Additional binding for the "OK" button
In the actions associated with the "OK" button—which is intended to save the parent record along with all child records—the write container must be added to the custom table.
Configuring the Custom Table
In the custom table, the input page from the subordinate data group must be included.
Button for creating child records
In the actions for the button that inserts child records into the custom table, you must select the "Add Record" action type with the "Custom Table" control and the "STRID" parameter.
Summary
What makes this example unique is the fact that the parent data record has not yet been created before the child data records are created. In this case, a unique ID must be generated for the parent record. This is achieved using the fallback value "uniqueGuid," which automatically generates a new GUID. This value must then be passed to the input page of the free-form table using the "Add Child Record" button. This dependency requires that the foreign key be present accordingly.








