Before deleting a record in the Orders table, check for related items in the OrderDetails table. Add the following code to the List page: Before record deleted event.
// $deleted_values contains the list of deleted rows key columns
$sql = "select from OrderDetails where OrderID=".$deleted_values["OrderID"];
$rs = DB::Query($sql);
$data = $rs->fetchAssoc();
if($data)
return false;
else
return true;
See also:
•Check if specific record exists
•Master-details relationship between tables