Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

How to change Code unit for custom added columns update

Posted on by 10
I am sharing with you the code in AL, for code unit extension where I am trying to update and pass values into posted entry tables like 21,17, posted documents, etc.
Please suggest or correct my syntax because I am new to Coding.  The colored code is added to initiate data flow from unposted to post. 
warm regards
krish chowdary 
Codeunit 50105 BGS_SalesPostCu
{
    Permissions = tabledata BGS_Areas = RIMD,
        tabledata "Cust. Ledger Entry" = RIMD,
        tabledata "G/L Entry" = RIMD,
        tabledata "Sales Invoice Header" = RIMD,
        tabledata "Item Ledger Entry" = RIMD,
        tabledata "Fixed Asset" = RIMD,
        tabledata "FA Ledger Entry" = RIMD,
        tabledata "Posted Assembly Header" = RIMD,
        tabledata "Posted Assembly Line" = RIMD,
        tabledata "Sales Invoice Line" = RIMD,
        tabledata "Detailed Cust. Ledg. Entry" = RIMD;
    //---------------
    [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."Consumer Id" := SalesHeader."Consumer Id";

    end;

    //----------------
    [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;

    var
        invoicePostingBuff: Record "Invoice Posting Buffer";
        InvvoicePosting: Interface "Invoice Posting";

}
  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: How to change Code unit for custom added columns update

    I think it will work, you can test it.

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,228 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