In this post, I will consolidate the commonly used events to transfer custom fields to posted table and ledger entry.
Depending on your needs, this may not be the only event available, as there are other events that might better align with your specific requirements.
- Order to Receipt/Shipment and Invoice (Header and Line)
- Purchase Module Events
- Sales Module Events
- Invoice Posting Buffer
- Journal Events
- Item Module Events
- Fixed Asset Module Events
- Transfer Order Module Events
- Transfer Header (5740) to Direct Trans. Header (5856)
- Transfer Line (5741) to Direct Trans. Line (5857)
- Transfer Header (5740) to Transfer Shipment Header (5744)
- Transfer Line (5741) to Transfer Shipment Line (5745)
- Transfer Header (5740) to Transfer Receipt Header (5746)
- Transfer Line (5741) to Transfer Receipt Line (5747)
1. Order to Receipt/Shipment and Invoice (Header and Line)
When an order is posted, the standard event will run the ‘TransferFields’ function to copy the fields from source table to the target table. The function will take care of the transferring and there is no need to subscribe to any event as long as the Field ID is the same across the tables.
To keep it clean, it will be best to use the same Field Name and Field Type to ensure the process smooth.
2. Purchase Module Events
Refer to #5-Journal Events and #6-Item Events for posting to ledger.
2.1 Purchase Header (38) to Gen. Journal Line (81)
[EventSubscriber(ObjectType::Table, Database::"Gen. Journal Line", OnAfterCopyGenJnlLineFromPurchHeader, '', false, false)]
local procedure "OnAfterCopyGenJnlLineFromPurchHeader"(PurchaseHeader: Record "Purchase Header"; var GenJournalLine: Record "Gen. Journal Line")
begin
end;
2.2 Purchase Line (39) to Invoice Posting Buffer (55)
[EventSubscriber(ObjectType::Table, Database::"Invoice Posting Buffer", OnAfterPreparePurchase, '', false, false)]
local procedure "OnAfterPreparePurchase"(var PurchaseLine: Record "Purchase Line"; var InvoicePostingBuffer: Record "Invoice Posting Buffer" temporary)
begin
end;
2.3 Purchase Header (38) to Item Journal Line (83)
[EventSubscriber(ObjectType::Table, Database::"Item Journal Line", OnAfterCopyItemJnlLineFromPurchHeader, '', false, false)]
local procedure "OnAfterCopyItemJnlLineFromPurchHeader"(var ItemJnlLine: Record "Item Journal Line"; PurchHeader: Record "Purchase Header")
begin
end;
2.4 Purchase Line (39) to Item Journal Line (83)
[EventSubscriber(ObjectType::Table, Database::"Item Journal Line", OnAfterCopyItemJnlLineFromPurchLine, '', false, false)]
local procedure "OnAfterCopyItemJnlLineFromPurchLine"(var ItemJnlLine: Record "Item Journal Line"; PurchLine: Record "Purchase Line")
begin
end;
3. Sales Module Events
Refer to #5-Journal Events and #6-Item Events for posting to ledger.
3.1 Sales Header (36) to Gen. Journal Line (81)
[EventSubscriber(ObjectType::Table, Database::"Gen. Journal Line", OnAfterCopyGenJnlLineFromSalesHeader, '', false, false)]
local procedure "OnAfterCopyGenJnlLineFromSalesHeader"(SalesHeader: Record "Sales Header"; var GenJournalLine: Record "Gen. Journal Line")
begin
end;
3.2 Sales Line (37) to Invoice Posting Buffer (55)
[EventSubscriber(ObjectType::Table, Database::"Invoice Posting Buffer", OnAfterPrepareSales, '', false, false)]
local procedure "Invoice Posting Buffer_OnAfterPrepareSales"(var SalesLine: Record "Sales Line"; var InvoicePostingBuffer: Record "Invoice Posting Buffer" temporary)
begin
end;
3.3 Sales Header (36) to Item Journal Line (83)
[EventSubscriber(ObjectType::Table, Database::"Item Journal Line", OnAfterCopyItemJnlLineFromSalesHeader, '', false, false)]
local procedure "OnAfterCopyItemJnlLineFromSalesHeader"(var ItemJnlLine: Record "Item Journal Line"; SalesHeader: Record "Sales Header")
begin
end;
3.4 Sales Line (37) to Item Journal Line (83)
[EventSubscriber(ObjectType::Table, Database::"Item Journal Line", OnAfterCopyItemJnlLineFromSalesLine, '', false, false)]
local procedure "OnAfterCopyItemJnlLineFromSalesLine"(var ItemJnlLine: Record "Item Journal Line"; SalesLine: Record "Sales Line")
begin
end;
4. Invoice Posting Buffer
Refer to #5-Journal Events for posting to ledger.
4.1 Invoice Posting Buffer (55) to Gen. Journal Line (81)
[EventSubscriber(ObjectType::Table, Database::"Invoice Posting Buffer", OnAfterCopyToGenJnlLine, '', false, false)]
local procedure "OnAfterCopyToGenJnlLine"(var GenJnlLine: Record "Gen. Journal Line"; InvoicePostingBuffer: Record "Invoice Posting Buffer" temporary)
begin
end;
5. Journal Events
5.1 Gen. Journal Line (81) to G/L Entry (17)
[EventSubscriber(ObjectType::Table, Database::"G/L Entry", OnAfterCopyGLEntryFromGenJnlLine, '', false, false)]
local procedure "OnAfterCopyGLEntryFromGenJnlLine"(var GLEntry: Record "G/L Entry"; var GenJournalLine: Record "Gen. Journal Line")
begin
end;
5.2 Gen. Journal Line (81) to VAT Entry (254)
[EventSubscriber(ObjectType::Table, Database::"VAT Entry", OnAfterCopyFromGenJnlLine, '', false, false)]
local procedure "OnAfterCopyFromGenJnlLine"(var VATEntry: Record "VAT Entry"; GenJournalLine: Record "Gen. Journal Line")
begin
end;
5.3 Gen. Journal Line (81) to Cust. Ledger Entry (21)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnAfterInitCustLedgEntry, '', false, false)]
local procedure "OnAfterInitCustLedgEntry"(var CustLedgerEntry: Record "Cust. Ledger Entry"; GenJournalLine: Record "Gen. Journal Line"; var GLRegister: Record "G/L Register")
begin
end;
5.4 Gen. Journal Line (81) to Vendor Ledger Entry (25)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnAfterInitVendLedgEntry, '', false, false)]
local procedure "OnAfterInitVendLedgEntry"(var VendorLedgerEntry: Record "Vendor Ledger Entry"; GenJournalLine: Record "Gen. Journal Line"; var GLRegister: Record "G/L Register")
begin
end;
5.5 Gen. Journal Line (81) to Bank Account Ledger Entry (271)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnAfterInitBankAccLedgEntry, '', false, false)]
local procedure "OnAfterInitBankAccLedgEntry"(var BankAccountLedgerEntry: Record "Bank Account Ledger Entry"; GenJournalLine: Record "Gen. Journal Line")
begin
end;
5.6 Gen. Journal Line (81) to FA Ledger Entry (5601)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"FA Jnl.-Post Line", OnBeforePostFixedAssetFromGenJnlLine, '', false, false)]
local procedure "OnBeforePostFixedAssetFromGenJnlLine"(var GenJournalLine: Record "Gen. Journal Line"; var FALedgerEntry: Record "FA Ledger Entry"; FAAmount: Decimal; VATAmount: Decimal; GLRegisterNo: Integer)
begin
end;
6. Item Module Events
6.1 Item Journal Line (83) to Item Ledger Entry (32)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Line", OnAfterInitItemLedgEntry, '', false, false)]
local procedure "OnAfterInitItemLedgEntry"(var NewItemLedgEntry: Record "Item Ledger Entry"; var ItemJournalLine: Record "Item Journal Line"; var ItemLedgEntryNo: Integer)
begin
end;
6.2 Item Journal Line (83) to Value Entry (5802)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Line", OnAfterInitValueEntry, '', false, false)]
local procedure "OnAfterInitValueEntry"(var ValueEntry: Record "Value Entry"; var ItemJournalLine: Record "Item Journal Line"; var ValueEntryNo: Integer; var ItemLedgEntry: Record "Item Ledger Entry")
begin
end;
7. Fixed Asset Module Events
7.1 FA Journal Line (5621) to FA Ledger Entry (5601)
Refer to 5.6 Gen. Journal Line (81) to FA Ledger Entry (5601) for posting from ‘Fixed Asset G/L Journals’ .
This is ‘Fixed Asset Journals’ posting.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Make FA Ledger Entry", OnAfterCopyFromFAJnlLine, '', false, false)]
local procedure "OnAfterCopyFromFAJnlLine"(var FALedgerEntry: Record "FA Ledger Entry"; FAJournalLine: Record "FA Journal Line")
begin
end;
8. Transfer Order Module Events
8.1 Transfer Header (5740) to Direct Trans. Header (5856)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"TransferOrder-Post Transfer", OnAfterInsertDirectTransHeader, '', false, false)]
local procedure "OnAfterInsertDirectTransHeader"(var DirectTransHeader: Record "Direct Trans. Header"; TransferHeader: Record "Transfer Header")
begin
end;
8.2 Transfer Line (5741) to Direct Trans. Line (5857)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"TransferOrder-Post Transfer", OnAfterInsertDirectTransLine, '', false, false)]
local procedure "OnAfterInsertDirectTransLine"(var DirectTransLine: Record "Direct Trans. Line"; DirectTransHeader: Record "Direct Trans. Header"; TransLine: Record "Transfer Line")
begin
end;
8.3 Transfer Header (5740) to Transfer Shipment Header (5744)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"TransferOrder-Post Shipment", OnAfterInsertTransShptHeader, '', false, false)]
local procedure "OnAfterInsertTransShptHeader"(var TransferHeader: Record "Transfer Header"; var TransferShipmentHeader: Record "Transfer Shipment Header")
begin
end;
8.4 Transfer Line (5741) to Transfer Shipment Line (5745)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"TransferOrder-Post Shipment", OnAfterInsertTransShptLine, '', false, false)]
local procedure "OnAfterInsertTransShptLine"(var TransShptLine: Record "Transfer Shipment Line"; TransLine: Record "Transfer Line"; CommitIsSuppressed: Boolean; TransShptHeader: Record "Transfer Shipment Header")
begin
end;
8.5 Transfer Header (5740) to Transfer Receipt Header (5746)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"TransferOrder-Post Receipt", OnAfterInsertTransRcptHeader, '', false, false)]
local procedure "OnAfterInsertTransRcptHeader"(var TransRcptHeader: Record "Transfer Receipt Header"; var TransHeader: Record "Transfer Header")
begin
end;
8.6 Transfer Line (5741) to Transfer Receipt Line (5747)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"TransferOrder-Post Receipt", OnAfterInsertTransRcptLine, '', false, false)]
local procedure "OnAfterInsertTransRcptLine"(var TransRcptLine: Record "Transfer Receipt Line"; TransLine: Record "Transfer Line"; CommitIsSuppressed: Boolean; TransferReceiptHeader: Record "Transfer Receipt Header")
begin
end;