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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Flow data from sales Header to gl entry

(0) ShareShare
ReportReport
Posted on by 151

hello 

I want to flow data from sales header to gl entry. I have created field on sales header and gl entry. So as i post sales order i want that data to be flow to gl entry. So how  can we do that in busiuness central.

[EventSubscriber(ObjectType::Table, 81, 'OnAfterCopyGenJnlLineFromSalesHeader', '', false, false)]
       local procedure OnAfterCopyGenJnlLineFromSalesHeader(var GenJournalLine: Record "Gen. Journal Line";SalesHeader: Record "Sales Header")
       begin
           GenJournalLine."Nick Name":=SalesHeader."Practice Name";
       end;
       [EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnAfterPostCustomerEntry', '', false, false)]
       local procedure MyProcedure(var GenJnlLine: Record "Gen. Journal Line";var SalesHeader: Record "Sales Header")
       var
       glEntry: Record "G/L Entry";
       begin
           glEntry."Nick Name":=GenJnlLine."Nick Name";
           
       end;
I tried above code but not working . Any body can help?
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    Can you please change your code as per below?

       [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnAfterInitGLEntry', '', true, true)]

       local procedure OnAfterInitGLEntry(var GLEntry: Record "G/L Entry"; GenJournalLine: Record "Gen. Journal Line"; Amount: Decimal; AddCurrAmount: Decimal; UseAddCurrAmount: Boolean; var CurrencyFactor: Decimal)

       begin

              glEntry."Nick Name":=GenJnlLine."Nick Name";

       end;

       [EventSubscriber(ObjectType::table, database::"Gen. Journal Line", 'OnAfterCopyGenJnlLineFromSalesHeader', '', true, true)]

       local procedure OnAfterCopyGenJnlLineFromSalesHeader(SalesHeader: Record "Sales Header"; var GenJournalLine: Record "Gen. Journal Line")

       begin

              GenJournalLine."Nick Name":=SalesHeader."Practice Name";

       end;

  • Salba Z.K Profile Picture
    151 on at

    Thanks Nitin,

    It worked

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Great, Good to know that your problem is solved.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 545 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 354 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 228 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans