Skip to main content

Notifications

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

General Journal Line

Posted on by 130

when we add Fields in General Jounral line , once posted, the data in the field should have to take the value in the table Fixed Asset Ledgers, if you know can anybody help me. I am attaching my codeunit what I have done on this. I  used the event in the codeunit Gen.Jnl.post  but I  didn't get the value


    // [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnPostFixedAssetOnBeforeAssignGLEntry', '', false, false)]
    // local procedure OnPostFixedAssetOnBeforeAssignGLEntry(var GenJournalLine: Record "Gen. Journal Line"; var GLEntry: Record "G/L Entry"; var IsHandled: Boolean; var TempFAGLPostBuf: Record "FA G/L Posting Buffer" temporary; GLEntry2: Record "G/L Entry"; NextEntyNo: Integer;FALedgerEntry: Record "FA Ledger Entry")
    // begin
    //   FALedgerEntry."Product Name"   := GenJournalLine."Product Name";
    // end;
  • Suggested answer
    Vaishnavi J Profile Picture
    Vaishnavi J 3,056 on at
    RE: General Journal Line

    Hi,

    You can use below logic to write the add your values from general journal line to FA ledger entries

    codeunit 50125 PostFAProductNameCodeunit
    {
       
        Permissions = tabledata "FA Ledger Entry" = rimd;


        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnAfterPostGenJnlLine', '', false, false)]
        local procedure OnAfterPostGenJnlLine(var GenJournalLine: Record "Gen. Journal Line")
        var
            Rec_FaLedgerEntries: Record "FA Ledger Entry";
        begin
            Clear(Rec_FaLedgerEntries);
            Rec_FaLedgerEntries.Reset();
            if (GenJournalLine."Product Name" <> '') or (GenJournalLine."Account Type" = GenJournalLine."Account Type"::"Fixed Asset") then begin
                Rec_FaLedgerEntries.SetRange("Document No.", GenJournalLine."Document No.");
                Rec_FaLedgerEntries.SetRange("FA No.", GenJournalLine."Account No.");
                Rec_FaLedgerEntries.SetRange("Posting Date", GenJournalLine."Posting Date");
                if Rec_FaLedgerEntries.FindFirst() then begin
                    Rec_FaLedgerEntries."Product Name" := GenJournalLine."Product Name";
                    Rec_FaLedgerEntries.Modify(true);
                end;
            end;

        end;

    }

    If my answer was helpful to you, please verify it so that other users know it worked. Thank you very much

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans