Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,18 @@ codeunit 3904 "Apply Retention Policy Impl."
RetenPolDeleting.DeleteRecords(RecordRef, TempRetenPolDeletingParam);

if not TempRetenPolDeletingParam."Skip Event Indirect Perm. Req." then begin
ApplyRetentionPolicyFacade.OnApplyRetentionPolicyIndirectPermissionRequired(RecordRefDuplicate, Handled);
// Indirect-permission path: RecordRef is still open and retains its record marks.
// RecordRef.Duplicate() copies filters and the MarkedOnly flag but NOT the marks, so the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// subscriber must receive the original marked RecordRef - otherwise subset (marked) deletes
// would delete nothing. Count the remaining marked records, then close the original ref.
ApplyRetentionPolicyFacade.OnApplyRetentionPolicyIndirectPermissionRequired(RecordRef, Handled);
if not Handled then
RetentionPolicyLog.LogError(LogCategory(), StrSubstNo(IndirectPermissionsRequiredErr, RecordRefDuplicate.Number, RecordRefDuplicate.Caption));
RetentionPolicyLog.LogError(LogCategory(), StrSubstNo(IndirectPermissionsRequiredErr, RecordRef.Number, RecordRef.Caption));
Handled := false;
end;

RecordCountAfter := Count(RecordRefDuplicate);
RecordCountAfter := Count(RecordRef);
RecordRef.Close();
end else
RecordCountAfter := Count(RecordRefDuplicate);
NumberOfRecordsDeleted := RecordCountBefore - RecordCountAfter;
TotalNumberOfRecordsDeleted += NumberOfRecordsDeleted;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ codeunit 3916 "Reten. Pol. Delete. Impl." implements "Reten. Pol. Deleting"
LimitRecordsToBeDeleted(RecordRef, RecordReferenceIndirectPermission, RetenPolDeletingParam."Skip Event Rec. Limit Exceeded", RetenPolDeletingParam."Max. Number of Rec. To Delete", RetenPolDeletingParam."Total Max. Nr. of Rec. to Del.");
end;

if not RetenPolDeletingParam."Indirect Permission Required" then
if not RetenPolDeletingParam."Indirect Permission Required" then begin
RecordReferenceIndirectPermission.DeleteAll(RecordRef, true);
// Direct-permission path: close here. For the indirect-permission path the caller needs
// the still-open RecordRef (with its record marks intact) to raise
// OnApplyRetentionPolicyIndirectPermissionRequired, and closes it afterwards.
RecordRef.Close();
end;
RetenPolDeletingParam."Skip Event Indirect Perm. Req." := not RetenPolDeletingParam."Indirect Permission Required";
RecordRef.Close();
end;

local procedure LimitRecordsToBeDeleted(var RecordRef: RecordRef; RecordReferenceIndirectPermission: Interface "Record Reference"; var SkipOnApplyRetentionPolicyRecordLimitExceeded: Boolean; MaxNumberOfRecordsToDelete: Integer; TotalMaxNumberOfRecordsToDelete: Integer)
Expand Down
Loading