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

Posting specific document no journal through code

(0) ShareShare
ReportReport
Posted on by 44

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

I have the same question (0)
  • Suggested answer
    Govinda Kumar Profile Picture
    2,304 Moderator 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

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