mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-06 09:26:52 +01:00
Seed the first new AL knowledge domain toward issue #34: a fully wired error-handling domain that the review pipeline actually consumes. - 3 knowledge articles (+ good/bad AL samples): - prefer-errorinfo-for-actionable-errors (ErrorInfo Fix-it/Show-it actions) - collect-validation-errors-with-errorbehavior (ErrorBehavior::Collect) - errortype-internal-vs-client-for-diagnostics (ErrorType Internal vs Client) - New leaf skill al-error-handling-review.md, modeled on al-performance-review - Wire the leaf into al-code-review (sub-skills, Source, description) - README: six -> seven leaf skills Validated: frontmatter validator clean; knowledge-index check passes (deterministic, full coverage, selection inputs intact). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
44 lines
1.4 KiB
AL
44 lines
1.4 KiB
AL
table 50180 "Actionable Error Good Sample"
|
|
{
|
|
fields
|
|
{
|
|
field(1; "Entry No."; Integer) { }
|
|
field(2; "Qty. to Invoice"; Decimal)
|
|
{
|
|
trigger OnValidate()
|
|
var
|
|
CannotInvoiceErr: ErrorInfo;
|
|
begin
|
|
if "Qty. to Invoice" > MaxQtyToInvoice() then begin
|
|
CannotInvoiceErr.Title := 'Qty. to Invoice isn''t valid';
|
|
CannotInvoiceErr.Message := StrSubstNo('You cannot invoice more than %1 units.', MaxQtyToInvoice());
|
|
CannotInvoiceErr.DetailedMessage := 'Reduce the quantity to invoice, or apply the maximum allowed.';
|
|
CannotInvoiceErr.RecordId := Rec.RecordId();
|
|
CannotInvoiceErr.AddAction(
|
|
StrSubstNo('Set value to %1', MaxQtyToInvoice()),
|
|
Codeunit::"Actionable Error Fixit Sample",
|
|
'SetQtyToMax');
|
|
Error(CannotInvoiceErr);
|
|
end;
|
|
end;
|
|
}
|
|
}
|
|
|
|
local procedure MaxQtyToInvoice(): Decimal
|
|
begin
|
|
exit(10);
|
|
end;
|
|
}
|
|
|
|
codeunit 50181 "Actionable Error Fixit Sample"
|
|
{
|
|
procedure SetQtyToMax(SourceError: ErrorInfo)
|
|
var
|
|
Line: Record "Actionable Error Good Sample";
|
|
begin
|
|
if Line.Get(SourceError.RecordId) then begin
|
|
Line.Validate("Qty. to Invoice", 10);
|
|
Line.Modify(true);
|
|
end;
|
|
end;
|
|
}
|