bcquality/microsoft/knowledge/performance/use-tryfunction-for-error-catching-not-rollback.bad.al

17 lines
531 B
AL

codeunit 50156 "Perf Sample TryFunc Bad"
{
procedure ApplyDiscountAttempt(var Customer: Record Customer)
begin
if not TryApplyDiscount(Customer) then
Message('Discount not applied');
end;
[TryFunction]
local procedure TryApplyDiscount(var Customer: Record Customer)
begin
Customer.Validate("Customer Price Group", 'VIP');
Customer.Modify(true);
if Customer."Credit Limit (LCY)" <= 0 then
Error('Customer %1 not eligible', Customer."No.");
end;
}