BC Teardown #1: Your custom fields vanish when you post

BC Teardown #1: Your custom fields vanish when you post

The pain

You added a Project Code field to sales orders. Users fill it in every time. After posting, the invoice shows it blank and your reports break.

Why it happens

Posting copies the header with TransferFields, which matches fields by field number. If the posted table has no field with that number, the value is silently dropped.

Before: Field only on the order

tableextension 50100 "DF Sales Header"
  extends "Sales Header"
{
  fields
  {
    field(50100; "DF Project Code"; Code[20])
    { }
  }
}

// Sales Invoice Header: no field 50100
// so the value never reaches the invoice

After: Same field number on the posted table

tableextension 50101 "DF Sales Inv. Header"
  extends "Sales Invoice Header"
{
  fields
  {
    field(50100; "DF Project Code"; Code[20])
    {
      Editable = false;
    }
  }
}

The result

The value flows to the posted invoice automatically. No posting code to write, nothing to break on upgrade.

Tip: Add the same field number to Sales Shipment Header and Sales Cr.Memo Header too.

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.