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...
Suggested Answer

Insert GLEntries when posting sales invoice

(0) ShareShare
ReportReport
Posted on by 10

Greetings, 

I have added a custom field on Sales Invoice Subform (Alpha) , and a field on Sales & Receivable Setup Page (Beta), I need to use the value of Alpha and post it to Beta which happens to be a GLAccount when a sales invoice is posted.

I need your help to pinpoint the event to subscribe to and how to get "Rec.Entry no" and other auto generated fields when posting the sales invoice from AL , I would truly appreciate your generous help :) 

  • Suggested answer
    IB-29041624-0 Profile Picture
    1,191 Moderator on at

    Just so i understand.

    You want to post an extra G/L Transaction for every posted salesinvoice line where you have a value in your customized field?

    In that case you would need both a g/l account and a balancing g/l account.

  • Lars Lohndorf-Larsen Profile Picture
    Microsoft Employee on at

    Hi,

    Codeunit 12 "Gen. Jnl.-Post Line" does most or all of the inserting of G/L entries, so I would look into that codeunit for useful events. For example OnAfterInsertGLEntry, like this:

    codeunit 50100 GLEvent

    {

       trigger OnRun()

       begin

       end;

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

       local procedure MyProcedure(GLEntry: Record "G/L Entry")

       begin

           Message(format(GLEntry."Entry No.") + '\' + GLEntry."G/L Account No.");

       end;

    }

  • Suggested answer
    Dallefeld Profile Picture
    235 User Group Leader on at

    I suggested discussing with your partner and proceeding with caution.

  • Suggested answer
    YUN ZHU Profile Picture
    103,712 Super User 2026 Season 2 on at

    Hi, You can check the standard posting codes in base application to find the available events.

    Or, try to use Event Recorder in BC.

    pastedimage1647994478125v1.png

    Use shortcut key ALT + SHIFT + E to search event in VS Code.

    pastedimage1647994552811v2.png

    But I still recommend the first method....

    Hope this info helps.

    Thanks.

    ZHU

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

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 676 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 483 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 310 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans