mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-06 15:16:56 +01:00
The AL Guidelines mark `SetLoadFields` placed before `SetRange`/`SetFilter` as bad code and recommend filters first, while the BCQuality samples used the opposite order — contradictory guidance across two Microsoft repos. Per Learn (`Record.SetLoadFields`), "fields that are filtered upon are always loaded", so the two orders produce an identical projection. The upstream rule is a readability convention: keep `SetLoadFields` adjacent to the read it governs. - Reorder filters ahead of `SetLoadFields` in the six affected AL samples. - State the placement convention in the Best Practice section. - Record in Description that order does not change the projection, and that only a fieldless `SetLoadFields()` or a later overwriting call does. - Add an Anti Pattern note so review agents treat the reverse order as a readability observation, never a performance defect. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
19 lines
666 B
AL
19 lines
666 B
AL
codeunit 50493 "Perf Record Clone Bad"
|
|
{
|
|
procedure IncreaseCustomerCreditLimits(Percent: Decimal)
|
|
var
|
|
Customer: Record Customer;
|
|
CustomerCopy: Record Customer;
|
|
begin
|
|
Customer.SetFilter("Credit Limit (LCY)", '>0');
|
|
Customer.SetLoadFields("Credit Limit (LCY)");
|
|
if Customer.FindSet(true) then
|
|
repeat
|
|
CustomerCopy.Copy(Customer);
|
|
CustomerCopy.Validate(
|
|
"Credit Limit (LCY)",
|
|
Round(CustomerCopy."Credit Limit (LCY)" * (1 + Percent / 100)));
|
|
CustomerCopy.Modify(true);
|
|
until Customer.Next() = 0;
|
|
end;
|
|
}
|