Number Series related error while posting Cash Receipt journal

Hi Everyone,

I have created a report to import some fields into the ‘cash receipt journal’ form. The importing works perfectly fine. There is a problem which arises when posting the Cash receipt journal after the import.

The error is related to the number series, The number series are created correctly during the import. However while posting it, I get this following errror.

Microsoft Dynamics NAV Classic

Document No. must be 100216 in Gen. Journal Line Journal Template Name=####,Journal Batch Name=####,Line No.=20000.


I have gone through the last used Number in the Number series form, It is stated as 100215. which is correct since the last line in the imported record is also 100215. But in the error it shows it should be 100216 and points to the 1st line number present in the batch.

I have also used the debugger to check where the problem comes from, The error comes from a standard code in codeunit 13 “Gen. Jnl.-Post Batch” shown below. where no changes were made.

TESTFIELD(“Document No.”,NoSeriesMgt.GetNextNo(GenJnlBatch.“No. Series”,“Posting Date”,FALSE));

Have anyone faced this issue before, I would be much obliged if anyone could advise me on what to do regarding this and how to proceed with this.

Many thanks,



Unless someone has changed something major in codeunit 13 - then your error message is due to your lines in your journal. Litterally millions of lines are posting using this codeunit every day.

What you can do is check if the abount balances for your lines per posting date and document no.

If you are sure that your lines are ok, then list a few of them in a response here and someone can probably tell you what is wrong by looking at the lines.

agree. make sure also that document no. is the next no. to last used number in the no. series.

Hi Palle,

Thanks for the response. I am looking into it as you said. The Cash receipt lines are.

Hi Imran,

Thanks for your response, Yes the No. series is correctly reflected.

If the Balancing Account Type and Balancing Account No. is filled out then your lines are ok and your first line should start with Document No. 100216, then 100217, 100218 etc. and NOT RCPT-XXXXXXX which is also what the error message told you.

Thanks for the insights, The Document No. shown in the image is correct, Previously I altered the error message for simplification. Heres the raw error text.

Microsoft Dynamics NAV Classic

Document No. must be RCPT-DEP00216 in Gen. Journal Line Journal Template Name=‘CASH RECEI’,Journal Batch Name=‘PROFORMAS’,Line No.=‘30000’.


Hello Mathan,
You may want to:

  1. Remove the number series attached
  2. Post the imported transactions
  3. Update the last used number in your number series to reflect the last number in your batch
  4. Re-attaching the number series.

Hi Koya temitope,

Thanks for your response. This seems to work. As it goes past the “checking balance” stage during posting and another error pops up. However the same error comes up when i import again using the report, This is the code which i used to call the NoSeriesManagement codeunit in the report. Can you say why this error occurs? Might be highly helpful knowing it.

Linenumber += 10000;

GenJourLine.“Journal Template Name” := GenJourLine2.“Journal Template Name”;
GenJourLine.“Journal Batch Name” := GenJourLine2.“Journal Batch Name”;
GenJourLine.“Line No.” := Linenumber;
GenJourLine.VALIDATE(“Posting Date”,TODAY);
GenJourLine.VALIDATE(“Document Type”,GenJourLine.“Document Type”::Payment);
GenJournalBatch.SETRANGE(“Journal Template Name”,GenJourLine2.“Journal Template Name”);
GenJournalBatch.SETRANGE(Name,GenJourLine2.“Journal Batch Name”);
GenJournalBatch.SETFILTER(“No. Series”,’<>%1’,’’);
DocumentNo := NoSeriesManagement.GetNextNo(GenJournalBatch.“No. Series”,TODAY,TRUE);

GenJourLine.VALIDATE(“Document No.”,DocumentNo);

The code is not important, as it is working as intented!

If you set up a journal to use a number series - then you have to use that number series.

So KoyaTemitopes guide is correct.

The problem with your import is that you have a Document No. in your import-file. So you should really just import your lines into a Journal where the Numberseries is not filled out in the Journal Name, or accept the configured no. series for that journal and leave out the Document No. from your file.

Hi palle,

There is no “Document No.” on the file. There’s only “Account no.” , Amount and “Applies to Doc no” present in the file. The rest auto-generated and coded in the process only report.

Just as you said the Number series which is currently used, It is the setuped one which is to be used in this journal.

weird as the lines in your screenshot says RCPT-XXXXXXX - so the code that generates the lines in your journal must be adding this document no.

So if you wanna look and change code, then take a look at your import/line generating function.

Nevertheless, you can do an easy fix just by removing Numberseries in the journal “setup” before you start the impor, should not take you more than 10 seconds to do.