Bertverbeek4PS / bc2adls

Exporting data from Dynamics 365 Business Central to Azure data lake storage or MS Fabric lakehouse
MIT License
60 stars 22 forks source link

Only 1 deleted record is send to the storage account #123

Closed WilcoHendriksen closed 6 months ago

WilcoHendriksen commented 6 months ago

version: "24.24.0.0"

Reproduction: step 1: Add 2 or more new customers step 2: Export data step 3: Delete the 2 new customers (they are in ADLSE Deleted Record table, see image) step 4: Export data step 5: The storage account only has 1 deleted record

deleted_records

` FixDeletedRecordThatAreInTable(ADLSEDeletedRecord);

        if EmitTelemetry then begin
            TableCaption := RecordRef.Caption();
            EntityCount := Format(ADLSEDeletedRecord.Count());
            CustomDimensions.Add('Entity', TableCaption);
            CustomDimensions.Add('Entity Count', EntityCount);
            ADLSEExecution.Log('ADLSE-010', 'Deleted records found', Verbosity::Normal, CustomDimensions);
        end;

        repeat
            ADLSEExecution.Log('ADLSE-010x', 'create fakerecord', Verbosity::Normal);
            ADLSEUtil.CreateFakeRecordForDeletedAction(ADLSEDeletedRecord, RecordRef);
            if ADLSECommunication.TryCollectAndSendRecord(RecordRef, ADLSEDeletedRecord."Entry No.", FlushedTimeStamp) then
                DeletedLastEntryNo := FlushedTimeStamp
            else
                Error('%1%2', GetLastErrorText(), GetLastErrorCallStack());
        until ADLSEDeletedRecord.Next() = 0;

` EntityCount := Format(ADLSEDeletedRecord.Count()); is correct, but CreateFakeRecordForDeletedAction is only called once... so i'm not sure what is wrong here.

I saw "FixDeletedRecordThatAreInTable" was added at some point. If we comment it out it works again. Maybe issue #110 is related.

Bertverbeek4PS commented 6 months ago

Thanks @WilcoHendriksen. I have analysed it and it was not in the CreateFakeRecordForDeletedAction function (I refactored it also with this PR). But when you deleted multiple records it was only exported it once. There was no findset in the repeater.