5050

Schema Drift

Integrations
Medium
Pro
table
json
staging
error-handling
api

Schema drift

Your webshop pushes orders into Business Central through a JSON webhook, and the payload has drifted across three API versions: v1 sent every number as a string, v2 silently dropped properties it considered empty, v3 sends explicit nulls and a bag of new properties your app has never heard of. The previous integration read every field with a one-line GetToken().AsValue().AsDecimal() chain — it worked in the demo and died on the first real payload. You are writing the replacement: a tolerant mapper that stages everything it can read, reports precisely what it could not, and never crashes on a payload that follows the contract below.

Requirements

The starter ships two staging tables — keep their names, field names and types exactly as given, because the grading tests read the staged records directly:

  • "Web Order Staging" — primary key "Import Id" (Code[20]); fields "Order No." (Code[20]), "Customer Name" (Text[100]), "Order Date" (Date), "Total Amount" (Decimal), "Currency Code" (Code[10]).
  • "Web Order Line Staging" — primary key "Import Id" (Code[20]) + Position (Integer); fields "Item No." (Code[20]), Description (Text[100]), Quantity (Decimal), "Unit Price" (Decimal).

Implement the codeunit named "Web Order Json Mapper" with exactly this public procedure:

procedure MapOrder(ImportId: Code[20]; Payload: Text; var Errors: List of [Text])

The payload

Root object properties, in contract order:

Property Shape Required Staged into
orderNo string yes "Order No."
customerName string no "Customer Name"
orderDate string, yyyy-MM-dd yes "Order Date"
totalAmount number, or string holding a number yes "Total Amount"
currencyCode string no "Currency Code"
lines array of line objects no one "Web Order Line Staging" record per element
The rest of the statement and 3 hints Unlock with Pro
ALBusiness Central 28.5
Pro
Pro problem

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
  • 13 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.

$10 / month
or $100 / year
Upgrade
This problem is part of Pro
Pro unlocks the full statement, tests, hints and solution. The code editor works on a computer.
Upgrade