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

Changes in Standard codeunit as codeunit extension

(0) ShareShare
ReportReport
Posted on by 13

Hi Can anyone help me with your suggestion the following codeunit Extension is correct.

It suggest to flow values into custom fields

-------

Codeunit 50105 BGS_SalesPostCu
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales Post Invoice", 'OnPostLedgerEntryOnAfterGenJnlPostLine', '', false, false)]
    local procedure OnPostLedgerEntryOnAfterGenJnlPostLine(var GenJnlLine: Record "Gen. Journal Line"; var SalesHeader: Record "Sales Header"; var TotalSalesLine: Record "Sales Line"; var TotalSalesLineLCY: Record "Sales Line"; CommitIsSuppressed: Boolean; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line");
    begin
        GenJnlLine."Consumer Id" := SalesHeader."Consumer Id";
    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnAfterPostCustomerEntry', '', false, false)]
    local procedure OnAfterPostCustomerEntry(var GenJnlLine: Record "Gen. Journal Line"; var SalesHeader: Record "Sales Header"; var TotalSalesLine: Record "Sales Line"; var TotalSalesLineLCY: Record "Sales Line"; CommitIsSuppressed: Boolean; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line");
    begin
        GenJnlLine."Consumer Id" := SalesHeader."Consumer Id";

    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnPostCustOnAfterInitCustLedgEntry', '', false, false)]
    local procedure OnPostCustOnAfterInitCustLedgEntry(var Sender: Codeunit "Gen. Jnl.-Post Line"; var GenJournalLine: Record "Gen. Journal Line"; var CustLedgEntry: Record "Cust. Ledger Entry"; Cust: Record Customer; CustPostingGr: Record "Customer Posting Group");
    begin
        CustLedgEntry."Consumer Id" := GenJournalLine."Consumer Id";
    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Assembly-Post", 'OnAfterPost', '', false, false)]
    local procedure OnAfterPost(var AssemblyHeader: Record "Assembly Header"; var AssemblyLine: Record "Assembly Line"; PostedAssemblyHeader: Record "Posted Assembly Header"; var ItemJnlPostLine: Codeunit "Item Jnl.-Post Line"; var ResJnlPostLine: Codeunit "Res. Jnl.-Post Line"; var WhseJnlRegisterLine: Codeunit "Whse. Jnl.-Register Line");
    begin
        PostedAssemblyHeader."Customer No" := AssemblyHeader."Customer No";
        PostedAssemblyHeader."Job Order No" := AssemblyHeader."Job Order No";
        PostedAssemblyHeader."Asset No" := AssemblyHeader."Asset No";
    end;



}
---------------------
I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    60,993 Super User 2025 Season 2 on at
    RE: Changes in Standard codeunit as codeunit extension

    Are you using the new extensible posting engine in the latest BC version?

  • Hafiz@d365 Profile Picture
    13 on at
    RE: Changes in Standard codeunit as codeunit extension

    I don't know about this.  Just I have a few new custom fields Chequeno, Cheque date, and Consumer id. These should go to GL, CLE

    I have created in My extension as an object VSC

  • Suggested answer
    Mohana Yadav Profile Picture
    60,993 Super User 2025 Season 2 on at
    RE: Changes in Standard codeunit as codeunit extension

    Please review these blog posts

    https://yzhums.com/18470/

    www.kauffmann.nl/.../

  • Hafiz@d365 Profile Picture
    13 on at
    RE: Changes in Standard codeunit as codeunit extension

    thanks

    it shows the features.

    I request my specific question.

    please.

    Admin warned me for long threading on my discussion. please..

  • Suggested answer
    Mohana Yadav Profile Picture
    60,993 Super User 2025 Season 2 on at
    RE: Changes in Standard codeunit as codeunit extension

    Which option is selected in Sales & receivables setup? answer depends on the option that you are using.

  • Hafiz@d365 Profile Picture
    13 on at
    RE: Changes in Standard codeunit as codeunit extension

    Mohana,

    I am not savvy and talented to understand and code immediately.I know basic AL syntax. That is why I am coming here.

    either invoice posting or Invoicing buffer, how to add a few lines mentioned in my code.

  • Suggested answer
    Mohana Yadav Profile Picture
    60,993 Super User 2025 Season 2 on at
    RE: Changes in Standard codeunit as codeunit extension

    If it is invoicing buffer then

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnBeforePostCustomerEntry', '', false, false)]

       local procedure OnBeforePostCustomerEntry(var GenJnlLine: Record "Gen. Journal Line"; var SalesHeader: Record "Sales Header"; var TotalSalesLine: Record "Sales Line"; var TotalSalesLineLCY: Record "Sales Line"; CommitIsSuppressed: Boolean; PreviewMode: Boolean; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line");

       begin

           GenJnlLine."Send to CLE from SH" := SalesHeader."Send to CLE from SH";

       end;

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

       local procedure OnPostCustOnAfterInitCustLedgEntry(var Sender: Codeunit "Gen. Jnl.-Post Line"; var GenJournalLine: Record "Gen. Journal Line"; var CustLedgEntry: Record "Cust. Ledger Entry"; Cust: Record Customer; CustPostingGr: Record "Customer Posting Group");

       begin

           CustLedgEntry."Send to CLE from SH" := GenJournalLine."Send to CLE from SH";

       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

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