T
|
thamestrader 2/2/2022 |
I think you have almost got to the solution. Stick with the Before Add event, keep the SQL query to obtain the required information and than use it to populate the variable in the $values array. I don't see any need to use DB Insert, just make sure the fields you are defaulting are included on the view being used. I've pasted in code from my applciation that does precisely the same thing as you require. See code below which I have placed in the Before Record Added Event, this populates fields in the detail record about to be added with default data. Some are fixed values others variable that come from a Master record. The detail fields voucher_type, order_status and agency_ref have to be defined in the table or custom view being used in order to be in the $value array, but they are not displayed on the add page. $values["voucher_type"] = "Agency"; If you want to prefill fields before the Add page is displayed use the Processrecord values Event for the code. $values["Agency_id"] = $_SESSION["AG_id"]; In this example I am prefilling with a constant I am also using data held in a session variable that was populated when the user logged on that was obtained from their User record using the After Successful Login event of the Login Page. $_SESSION["AG_id"] = $data["AG_id"]; |