
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
:
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
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