Actions Example 8: Automatic Insert in Child Table and Related Box

Previous Next

See Also

In this info window with embedded child box, the frequent action of adding the customer booking the reservation (parent box) as a participant (child box) is supported by a button. The button was inserted at the level of the info window, not the related box.

Set the Action property of the Add Person Booking button to:

RecordStore(QUIET)

SqlScript

(

INSERT INTO participant(person_id,res_id,insurance)

VALUES(:MADE_BY,:RES_ID,'N')

)

Participants_taking_part_in_Reservation.QueryExecute()

Participants_taking_part_in_Reservation.query.person_id.esd_int.ControlSetFocus()

Use the Object Activator to compose this method call script. The RecordStore method call acts at the top-level info box (the parent box) and therefore does not need an explicit object identifier. This method call is necessary to make sure the parent record is completed and a customer is known.

:MADE_BY and :RES_ID are embedded method calls. The INSERT statement can also be spelled as follows; in which case the method calls can be produced by using the Object Activator as a stand-alone editor:

INSERT INTO participant(person_id,res_id,insurance)

VALUES(:"query.made_by()",:"query.res_id()",'N')

)

After the INSERT action, all the Participant records for this Reservation are retrieved (including the newly added INSERT), and the cursor jumps to the first field of the Participants box.