Skip to main content

Pattern B — EventSubscriber Event Map

Use this map when the posting codeunit does NOT call TransferFields from the source to the target. You must:

  1. Extend the source table with a TableExt (same Field ID as on target).
  2. Extend the target table with a TableExt (same Field ID).
  3. Create a dedicated EventSubscriber codeunit for the module — one codeunit per posting chain, not one per field.

How to confirm Pattern B applies

Open the BC posting codeunit. Search for TransferFields between the source record variable and the target insert variable. If TransferFields is absent, you need a subscriber using one of the events below.


Event Map

Source TableSource IDTarget TableTarget IDPosting CodeunitCodeunit IDEvent Name
Item Journal Line83Item Ledger Entry32Item Jnl.-Post Line22OnBeforeInsertItemLedgEntry
Item Journal Line83Capacity Ledger Entry5832Item Jnl.-Post Line22OnBeforeInsertCapLedgEntry
Item Journal Line83Value Entry5802Item Jnl.-Post Line22OnBeforeInsertValueEntry
Gen. Journal Line81Cust. Ledger Entry21(Table event)Table 21OnAfterCopyCustLedgerEntryFromGenJnlLine
Gen. Journal Line81Vendor Ledger Entry25(Table event)Table 25OnAfterCopyVendLedgerEntryFromGenJnlLine
Gen. Journal Line81G/L Entry17Gen. Jnl.-Post Line12OnAfterInsertGLEntry
Resource Journal Line207Res. Ledger Entry203Res. Jnl.-Post Line212OnAfterInsertResLedgEntry
Cash Flow Worksheet Line841Cash Flow Forecast Entry840Cash Flow Wksh.-Register Line843OnAfterCreateForecastEntry
Routing Line99000758Prod. Order Routing Line5409Calculate Prod. Order99000773OnAfterTransferRoutingLine
Assembly Header900Posted Assembly Header910Assembly-Post900OnAfterPostAssemblyHeader
Assembly Line901Posted Assembly Line911Assembly-Post900OnAfterPostAssemblyLine
Warehouse Receipt Line7317Posted Whse. Receipt Line7319Whse.-Post Receipt5760OnAfterPostWhseRcptLine
Warehouse Shipment Line7321Posted Whse. Shipment Line7323Whse.-Post Shipment5763OnAfterPostWhseShptLine
Payment Order (ES)7000006Cartera Doc.7000001Bill Groups-Post (ES)7000000OnAfterInsertPayableDocs

Note: The Payment Order → Cartera Doc. entry applies only to Spanish Cartera localization. Omit it if the extension targets a non-ES market.

Note: Res. Ledger Entry — the OnAfterInsertResLedgEntry event is raised inside Codeunit 212 ("Res. Jnl.-Post Line"). If that event is not accessible in your BC version, use OnBeforeInsertResLedgEntry or a local procedure integration event exposed by the posting codeunit.


Subscriber Codeunit Structure (per module)

One dedicated codeunit per module/posting chain. Do not mix subscribers from different posting chains in the same codeunit.

codeunit 50XXX "Ev[PostingChain][ModuleName]"
{
// Subscribes to ONE posting chain (e.g., Item Journal Line posting)
// All fields for this module from that chain go here.

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Line",
'OnBeforeInsertItemLedgEntry', '', false, false)]
local procedure OnBeforeInsertItemLedgEntry(var ItemLedgerEntry: Record "Item Ledger Entry";
ItemJournalLine: Record "Item Journal Line")
begin
ItemLedgerEntry.MyCustomField := ItemJournalLine.MyCustomField;
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Line",
'OnBeforeInsertCapLedgEntry', '', false, false)]
local procedure OnBeforeInsertCapLedgEntry(var CapacityLedgerEntry: Record "Capacity Ledger Entry";
ItemJournalLine: Record "Item Journal Line")
begin
CapacityLedgerEntry.MyCustomField := ItemJournalLine.MyCustomField;
end;
}

Field ID Alignment Rule

Always use the same Field ID on both the source TableExt and the target TableExt. This makes future migration to Pattern A trivial if BC later exposes a TransferFields path, and keeps IDs auditable across the extension.

// Source: Item Journal Line TableExt
field(50100; MyCustomField; Text[50]) { ... }

// Target: Item Ledger Entry TableExt — same ID
field(50100; MyCustomField; Text[50]) { ... }

// Target: Capacity Ledger Entry TableExt — same ID
field(50100; MyCustomField; Text[50]) { ... }