Master Detail Link not populating detail field value from master

This was working with previous version but not now with With a master detail link via a TDatasource and detail TXDataset linked using a parameter matching field from the master TXDataset the detail TXDataset field value is not being populated with the master value when Inserting. Simply swapping to Firedac (TFDQuery) components with all sql's the same, it works.

Thank you for the sample project sent via private message.

However, I must say that RemoteDB never filled the detail field value from master. We reverted our code here back to 2.13 version, and even back to 2.10 version, for example, and none of them fills such field.

There is not trace of any code in RemoteDB source code that resembles filling the detail field value.

Sorry, I have an in between class (inherits from TXDataset) that I have created to help with our conversion from FIB to RemoteDB I think I remember having to add this functionality in the new class to cater for the master detail parameter. I will have to look into why its no longer working.
That being said if we had not created a dataset conversion class we would certainly have needed this functionality, should that be a part of the TXDataset?

I have looked into the Firedac code to see how this is done and have added similar code to the RemoteDB.Client.Dataset unit and it now works, the function GetDetailLinkFields was already there so looks like this was half done already. Are you able to add this or similar to the code so I don't need to add it each update please

procedure TBaseXDataset.DoOnNewRecord;
i,iCount : Integer;
oMasters, oDetails: TXFieldList;
{Added to fill detail field values from master params}
if (DataSource <> nil) and (DataSource.DataSet <> nil) and
DataSource.DataSet.Active then begin
oMasters := TXFieldList.Create;
oDetails := TXFieldList.Create;
GetDetailLinkFields(oMasters, oDetails);
iCount := oMasters.Count;
if iCount > oDetails.Count then
iCount := oDetails.Count;
for i := 0 to iCount - 1 do
if oDetails[i].CanModify then
{END: Added to fill detail field values from master params}

// if a DefaultExpression exists, fill data with default

for i:=0 to Fields.Count-1 do
// largeint is not supported in variants
if (Fields[i].DataType <> ftLargeInt) and
(Fields[i].DefaultExpression <> '')
TField(Fields[i]).Value := TField(Fields[i]).DefaultExpression;

1 Like

Thank you for the follow up. Yes, we can add such code (enabled by using the property AutoFillDetailFields, to avoid breaking existing code.