-
Notifications
You must be signed in to change notification settings - Fork 31
LC0074
Arthur van de Vondervoort edited this page Nov 30, 2024
·
2 revisions
This rule detects direct assignments to FlowFilter
fields in AL code. Directly assigning values to these fields bypasses their intended functionality and invalidates the filtering logic used for calculations in FlowField fields. Instead, you should use the .SetFilter()
or .SetRange()
methods to properly set filters and ensure accurate results.
procedure GetInventory(ItemNo: Code[20]; LocationCode: Code[10]): Decimal
var
Item: Record Item;
begin
Item."No." := ItemNo;
Item."Location Filter" := LocationCode; // Direct assignment to a FlowFilter field
Item.CalcFields(Inventory);
exit(Item.Inventory);
end;
This now returns Inventory of all the Location Codes. The right way to handle this is using the .SetFilter()
or .SetRange()
method.
procedure GetInventory(ItemNo: Code[20]; LocationCode: Code[10]): Decimal
var
Item: Record Item;
begin
Item."No." := ItemNo;
Item.SetRange("Location Filter", LocationCode);
Item.CalcFields(Inventory);
exit(Item.Inventory);
end;