5000

Delete the Header, Leave No Orphans

Basics
Easy
Pro
table
ondelete
cascade-delete
header-lines

Delete the Header, Leave No Orphans

Header–lines pairs are everywhere in Business Central — Sales Header and Sales Line being the classic. Two rules keep such a pair healthy: deleting the header must take its lines with it, and a posted document must never be deletable. Both rules belong in the header table's OnDelete trigger — and both silently vanish whenever code deletes with triggers switched off. This task makes you feel exactly where that line runs.

What you are given

The starter contains two tables. "Work Order Line" is finished — submit it unchanged. "Work Order" compiles but its OnDelete trigger is empty, so today it deletes cleanly and leaves every line orphaned.

  • Table "Work Order": field "No." (Code[20], PK), Description (Text[100]), Posted (Boolean).
  • Table "Work Order Line": keyed "Work Order No." + "Line No.", with a Quantity (Decimal).
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
  • 7 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