Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Flow data from sales Header to gl entry

Posted on by 127

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?
Categories:
  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,025 Moderator on at
    RE: Flow data from sales Header to gl entry

    Great, Good to know that your problem is solved.

  • Salba Z.K Profile Picture
    Salba Z.K 127 on at
    RE: Flow data from sales Header to gl entry

    Thanks Nitin,

    It worked

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,025 Moderator on at
    RE: Flow data from sales Header to gl entry

    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;

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,645 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans