Please add Setcurrentkey for index “Document Type", Open, "Posting Date", "Closed at Date" to CalcAverageCollectionDays function in "Activities Mgt."(CodeUnit 1311) as calculation accessing Customer ledger entry is very slow.
Comments
I have included the missing setcurrentkey command in the comment below
Category: Development
local procedure GetPaidSalesInvoices(var CustLedgerEntry: Record "Cust. Ledger Entry")
begin
CustLedgerEntry.Setcurrentkey(“Document Type", Open, "Posting Date", "Closed at Date");
CustLedgerEntry.SetRange("Document Type", CustLedgerEntry."Document Type"::Invoice);
CustLedgerEntry.SetRange(Open, false);
CustLedgerEntry.SetRange("Posting Date", CalcDate('', GetDefaultWorkDate()), GetDefaultWorkDate());
CustLedgerEntry.SetRange("Closed at Date", CalcDate('', GetDefaultWorkDate()), GetDefaultWorkDate());
end;
Category: Development
The following AL code is slow as a result
AppObjectType: CodeUnit
AppObjectId: 1311
AL CallStack: "Activities Mgt."(CodeUnit 1311).CalcAverageCollectionDays line 8 - Base Application by Microsoft
"O365 Activities Dictionary"(CodeUnit 1310).OnRun(Trigger) line 9 - Base Application by Microsoft
Category: Development