Collect Every Error, With Payload
The nightly import feeds journal lines into Business Central, and the current pre-check is worse than useless: it dies on the first broken line and reports a bare text message. The operators want the opposite — one pass over the whole batch that reports every defect at once, each one carrying a machine-readable payload (which record, which field, which check) so the client UI can list them and jump straight to the offending line. Your job is that checker.
What you get
The starter ships three objects. Keep all three exactly as given and include them in your submission — the grading tests reference them by name.
- Table
"Import Journal Line": primary key"Batch Code"(Code[20]) +"Line No."(Integer), plus"Item Code"(Code[20]),Quantity(Decimal) and"Unit Cost"(Decimal). - Codeunit
"Item Registry"withprocedure RequireKnownItem(ImportJournalLine: Record "Import Journal Line")— a sealed stand-in for the company's item registry. An"Item Code"starting withGHOSTis unregistered: the registry rejects it by raising a collectible error that already carries its full payload — the line'sRecordId, the"Item Code"field number, and the custom dimensionsCheck=UNKNOWN_ITEM,LineNo, andProbe(a fresh token stamped into both the dimension and the message text at call time). A caller that collects errors gathers the rejection and keeps running; a caller that doesn't dies on the spot. Any other item code — including an empty one — passes the registry silently. - Codeunit
"Registry Probe Log"— a single-instance log the registry reports into: it counts everyRequireKnownItemcall per line and records the probe token of each rejection. The grading tests read it; your own code never needs to call it.
Requirements
Implement the codeunit named "Import Journal Validator" with one public procedure:
procedure CheckBatch(BatchCode: Code[20]; var Defects: List of [ErrorInfo])Solve it with Pro
You’re reading the opening of the statement. Pro unlocks the whole problem:
- The full statement
- Starter code in the browser editor
- 10 grading tests, run on Business Central 28.5
- 3 hints
- The reference solution
Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.
Already on Pro? Sign in