AL icon indicating copy to clipboard operation
AL copied to clipboard

DeleteMultiple cannot be used with filters when a companion table is present for the specified record

Open renebrummel opened this issue 8 years ago • 2 comments

Please advise on the following issue. Is it a bug or expected behavior?

Recently I added a function on the Job Queue Log Entries page to delete selected records. I also extended the Job Queue Log Entry table with two fields.

When I do a deleteall on my selection I get this error message: image

Code looks like this:

local procedure DeleteSelected();
var
    JobQueueLogEntry : Record "Job Queue Log Entry";
begin
    CurrPage.SetSelectionFilter(JobQueueLogEntry);
    if Confirm(StrSubstNo(AreYouSureQst, CurrPage.Caption()), false) then
        JobQueueLogEntry.DeleteAll(true);
end;

var
    AreYouSureQst : Label 'Are you sure you want to delete these %1?', comment = '%1 is the page caption';

renebrummel avatar Nov 06 '18 08:11 renebrummel

What you are seeing is a platform defect. When an efficient SQL bulk operation cannot be performed (triggers exist, events exist, companion tables exist + filters/marks, etc...) the platform should be automatically handling the DELETEALL as a loop using FIND and DELETE. No change to AL is needed - this is transparent.

There seems to be a defect where the presence of marked records is not causing this fallback. We need to fix this in the platform.

A short-term workaround would be to replace the call to DELETEALL with a FIND/DELETE loop to mimic what the platform is already going to do to the code at runtime.

cmrudolph-msft avatar Nov 20 '18 16:11 cmrudolph-msft

Thanks for getting back to me. I had already created a workaround with a repeat loop which works fine.

renebrummel avatar Nov 21 '18 07:11 renebrummel