web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Flow data from Purchase line to G/l Entry etc

(4) ShareShare
ReportReport
Posted on by 8
Hello Everyone,
 
I have created one field which is posting description on purchase line then the same description of item will come in posting description and then posting description data will flow in G/l Entry, Item Ledger Entry, Posted Purchase Receipt line, Posted purchase Invoice these entity. which Events should i subscribe and then how the data will flow in business central.
 
Please suggest
Thank you
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,307 Super User 2025 Season 2 on at
    Flow data from Purchase line to G/l Entry etc
    Hi, I happen to have an example of Purchase Header to Item Ledger Entry here, I hope it can give you some tips.
    codeunit 50112 MyCodeunit
    {
        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch.-Post", OnPostItemJnlLineOnAfterDocumentFields, '', false, false)]
        local procedure OnPostItemJnlLineOnAfterCopyDocumentFields(var ItemJournalLine: Record "Item Journal Line"; PurchaseLine: Record "Purchase Line"; WarehouseReceiptHeader: Record "Warehouse Receipt Header"; WarehouseShipmentHeader: Record "Warehouse Shipment Header"; PurchRcptHeader: Record "Purch. Rcpt. Header");
        begin
            ItemJournalLine."Purch Document No." := PurchaseLine."Document No.";
        end;
        [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
            NewItemLedgEntry."Purch Document No." := ItemJournalLine."Purch Document No.";
        end;
    }
    tableextension 50112 MyExtension extends "Item Journal Line"
    {
        fields
        {
            field(50000; "Purch Document No."; Code[20])
            {
                Caption = 'Purch Document No.';
                DataClassification = CustomerContent;
            }
        }
    }
    tableextension 50113 MyExtension2 extends "Item Ledger Entry"
    {
        fields
        {
            field(50000; "Purch Document No."; Code[20])
            {
                Caption = 'Purch Document No.';
                DataClassification = CustomerContent;
            }
        }
    }
    pageextension 50113 MyExtension extends "Item Ledger Entries"
    {
        layout
        {
            addafter("Document No.")
            {
                field("Purch Document No."; Rec."Purch Document No.")
                {
                    ApplicationArea = All;
                }
            }
        }
    }
     
    Thanks.
    ZHU
  • Suggested answer
    Aman Kakkar Profile Picture
    2,223 on at
    Flow data from Purchase line to G/l Entry etc
    Hey,
     
    You can easily do it using the following sequence of Standard Events for transferring data of a custom field from Purchase Line to GL Entry.
     
    Firstly create the "Custom Field" in the table extensions for Purchase Line, Invoice Posting Buffer, Gen. Journal Line and G/L Entry. Then go ahead with the below mentioned sequence of code.
     
    SEQUENCE: Purchase Line -> Invoice Posting Buffer -> Gen. Journal Line -> G/L Entry.
     
    Below are the events (along with the code) that you can use directly.
     
     
    STEP 01: Purchase Line -> Invoice Posting Buffer
     
    Use 'OnPrepareLineOnAfterFillInvoicePostingBuffer' from Codeunit "Purch. Post Invoice Events".
     
        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch. Post Invoice Events", 'OnPrepareLineOnAfterFillInvoicePostingBuffer', '', false, false)]
        local procedure OnPrepareLineOnAfterFillInvoicePostingBuffer(var InvoicePostingBuffer: Record "Invoice Posting Buffer"; PurchLine: Record "Purchase Line"; var TempInvoicePostingBuffer: Record "Invoice Posting Buffer" temporary; var FALineNo: Integer; var InvDefLineNo: Integer; var DeferralLineNo: Integer; var IsHandled: Boolean)
        begin
            InvoicePostingBuffer."Custom Field" := PurchLine."Custom Field";
        end;
     
     
    STEP 02: Invoice Posting Buffer -> Gen. Journal Line
     
    Use 'OnPrepareGenJnlLineOnAfterCopyToGenJnlLine' from Codeunit "Purch. Post Invoice Events"
     
        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch. Post Invoice Events", 'OnPrepareGenJnlLineOnAfterCopyToGenJnlLine', '', false, false)]
        local procedure OnPrepareGenJnlLineOnAfterCopyToGenJnlLine(var GenJnlLine: Record "Gen. Journal Line"; PurchHeader: Record "Purchase Header"; InvoicePostingBuffer: Record "Invoice Posting Buffer")
        begin
            GenJnlLine."Custom Field" := InvoicePostingBuffer."Custom Field";
        end;
     
     
    STEP 03: Gen. Journal Line -> G/L Entry
     
    Use 'OnAfterInitGLEntry' from Codeunit "Gen. Jnl.-Post Line"
     
        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnAfterInitGLEntry', '', false, false)]
    
        local procedure OnAfterInitGLEntry(var GLEntry: Record "G/L Entry"; GenJournalLine: Record "Gen. Journal Line"; Amount: Decimal; AddCurrAmount: Decimal; UseAddCurrAmount: Boolean; var CurrencyFactor: Decimal; var GLRegister: Record "G/L Register")
        begin
            GLEntry."Custom Field" := GenJournalLine."Custom Field";
        end;
     
     
    And that's it. You are done. Please do upvote and move it to Answers if you feel it helped you.
  • Suggested answer
    Yi Yong Profile Picture
    2,545 Super User 2025 Season 2 on at
    Flow data from Purchase line to G/l Entry etc
    Hello,
     
    For Purchase Line's Posting Description to Posted Purchase Receipt Line and Posted Purchase Invoice Line.
     
    For Purchase Line's Posting Description to G/L Entry.
    You will need to transfer to Invoice Posting Buffer > Gen. Journal Line > G/L Entry
     
    For Purchase Line's Posting Description to Item Ledger Entry,
    You will need to transfer to Item Journal Line > Item Ledger Entry.
  • Suggested answer
    Nimsara Jayathilaka. Profile Picture
    4,836 on at
    Flow data from Purchase line to G/l Entry etc
    Hi
     
    To flow your custom posting description field from Purchase Line into Posting Description in G/L Entry, Item Ledger Entry, Posted Purchase Receipt Line, and Posted Purchase Invoice in Business Central, you should:
     
    Subscribe to the OnBefore and OnAfter events related to the Purchase Line and posting processes in the following tables:
    • Purchase Line (to capture and assign your custom field before posting)
    • Gen. Journal Line or G/L Entry (for posting description flow to G/L Entries)
    • Item Ledger Entry (to transfer the description when creating ledger entries)
    • Posted Purchase Receipt Line and Posted Purchase Invoice Line (to ensure your field flows into posted documents)
    The data flow usually happens during the posting process: from purchase line during posting, the system creates item ledger entries, G/L entries, and posted document lines, transferring descriptions based on subscribers or extensions.
     
    You can implement event subscribers in AL to modify or copy your custom field to the standard Posting Description fields on these entities during posting events.
     
    In essence, subscribe to posting-related events on Purchase Line and posting tables like G/L Entry, Item Ledger Entry, Posted Purchase Receipt Line, and Posted Purchase Invoice Line, then code to map your custom description field accordingly during the posting workflow.
     
    Thanks
    Nimsara

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans