BC Teardown #3: Bad orders keep getting posted

BC Teardown #3: Bad orders keep getting posted

The pain

Orders ship without a shipping agent. Finance and the warehouse clean it up after the fact, every week.

Why it happens

The rule lives in a training document, not in the system. The old NAV fix was editing the posting codeunit, which breaks on every upgrade.

Before: The NAV way: edit base code

// Codeunit 80 "Sales-Post"
// modified directly in C/AL

// Every Microsoft update:
//   merge conflicts
//   retest everything
//   or the check quietly disappears

After: An event subscriber, base code untouched

codeunit 50110 "DF Sales Checks"
{
  [EventSubscriber(ObjectType::Codeunit,
    Codeunit::"Sales-Post",
    'OnBeforePostSalesDoc', '', false, false)]
  local procedure CheckOrder(
    var SalesHeader: Record "Sales Header")
  begin
    if SalesHeader."Document Type" =
      SalesHeader."Document Type"::Order then
      SalesHeader.TestField("Shipping Agent Code");
  end;
}

The result

Posting stops with a clear message before bad data gets in. The rule survives every BC update.

Tip: The same pattern works for purchase, transfer and warehouse posting events.

Download this teardown as a PDF


Got a Business Central problem like this? Free 30 minute review of your setup. Senior Microsoft certified developers, and you talk to the person writing the code. Contact Dataflow Solutions.