Master Detail foreign key not populated on insert
Make sure the foreign key in detail grid has the same field name as what's in the master grid.
"....The foreign key, or $fkey, does NOT necessarily have to have the same name as the master table primary key, as long as the same name exists in both master and detail tables. When foreign keys don’t have the same name, you should use SQL alias. ..."