Skip to main content

Notifications

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

Posting specific document no journal through code

Posted on by 26

Hi,

I am trying to post a journal with a specific document no through code, I am using the Gen Jnl Post codeunit but all the lines in the journal are being posted.

Ex

pastedimage1683817217868v1.png

I only want to post lines with doc no 12346, below is my code 

GenJnlLine.Reset();
GenJnlLine.SetFilter("Document No.", DocumentNo); //This is a variable being filled with the doc no to be posted
if GenJnlLine.FindFirst() then begin
Codeunit.Run(Codeunit::"Gen. Jnl.-Post", GenJnlLine);
end;

Thanks in advance

  • Suggested answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: Posting specific document no journal through code

    Hi,

    Try adding the 'Batch Name' filter, and use 'Find('-')' instead of 'FindFirst'

    GenJnlLine.Reset();
    GenJnlLine.SetFilter("Document No.", '=%1', DocumentNo); //This is a variable being filled with the doc no to be posted
    GenJnlLine.SetFilter("Journal Batch Name", '=%1', 'GCL')
    if GenJnlLine.Find('-') then begin
        Codeunit.Run(Codeunit::"Gen. Jnl.-Post", GenJnlLine);
    end;

    If possible, you can use other filters such as 'Document Type', etc

    Regards

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!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans