Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Changes in Standard codeunit as codeunit extension

Posted on by 83

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;



}
---------------------
  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,127 Super User 2024 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;

  • Hafiz@d365 Profile Picture
    Hafiz@d365 83 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
    Mohana Yadav 59,127 Super User 2024 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
    Hafiz@d365 83 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
    Mohana Yadav 59,127 Super User 2024 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
    Hafiz@d365 83 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
    Mohana Yadav 59,127 Super User 2024 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?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,219 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans