From 9aa2086f8fd16d076dba4f606a78574d55dddcfb Mon Sep 17 00:00:00 2001 From: Bert Verbeek Date: Tue, 30 Apr 2024 10:22:15 +0200 Subject: [PATCH] Fix for deleted records that are not exported. (#124) --- businessCentral/app/src/Execute.Codeunit.al | 34 +++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/businessCentral/app/src/Execute.Codeunit.al b/businessCentral/app/src/Execute.Codeunit.al index 41d9b55..f6ee3c4 100644 --- a/businessCentral/app/src/Execute.Codeunit.al +++ b/businessCentral/app/src/Execute.Codeunit.al @@ -246,13 +246,14 @@ codeunit 82561 "ADLSE Execute" ADLSEExecution.Log('ADLSE-010', 'Deleted records found', Verbosity::Normal, CustomDimensions); end; - repeat - 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; + if ADLSEDeletedRecord.FindSet() then + repeat + 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; if ADLSECommunication.TryFinish(FlushedTimeStamp) then DeletedLastEntryNo := FlushedTimeStamp @@ -268,17 +269,18 @@ codeunit 82561 "ADLSE Execute" RecordRef: RecordRef; begin //Because of the merge function of Contact, Vendor and customer - case ADLSEDeletedRecord."Table ID" of - 18, 23, 5050: - begin - RecordRef.Open(ADLSEDeletedRecord."Table ID"); - if ADLSEDeletedRecord.FindSet() then - repeat + if ADLSEDeletedRecord.FindSet() then + repeat + case ADLSEDeletedRecord."Table ID" of + 18, 23, 5050: + begin + RecordRef.Open(ADLSEDeletedRecord."Table ID"); if RecordRef.GetBySystemId(ADLSEDeletedRecord."System ID") then - ADLSEDeletedRecord.Delete(); - until ADLSEDeletedRecord.Next() = 0; + ADLSEDeletedRecord.Delete(false); + RecordRef.Close(); + end; end; - end; + until ADLSEDeletedRecord.Next() = 0; end; procedure CreateFieldListForTable(TableID: Integer) FieldIdList: List of [Integer]