bcquality/microsoft/knowledge/error-handling/fielderror-vs-testfield.bad.al
Jesper Schulz-Wedde 3d29c172a9
Promote validated community knowledge (#105)
Move eight net-new rules into the Microsoft layer, remove six overlapping articles, and update review skill discovery and references.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0b130227-d418-4bc0-9e7d-ec6a37adf039

Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com>
2026-07-14 14:20:27 +02:00

26 lines
791 B
AL

table 50122 "FieldError vs TestField Bad"
{
fields
{
field(1; "No."; Code[20]) { }
field(2; "Posting Date"; Date) { }
field(3; "Amount"; Decimal) { }
}
procedure PostDocument()
begin
// FieldError performs no comparison and raises as soon as it is
// reached, so this "check" terminates PostDocument every time — the
// Posting Date is never actually tested, and the amount rule below is
// dead code.
FieldError("Posting Date", 'must be filled in');
if IsAmountOutsideAllowedRange("Amount") then
Error('Amount is out of range.');
end;
local procedure IsAmountOutsideAllowedRange(Value: Decimal): Boolean
begin
exit((Value < 0) or (Value > 1000000));
end;
}