How to create a General Journal Line without filling the "Line No" field?

jeqdevjeqdev Member Posts: 8
Hi,

I am trying to create an standard General Journal line from a codeunit in NAV. The code in my codeunit is like that:
//Journal is type: Record, Subtype: 81 (table Gen. Journal Line)
//Do Loop
  Journal.INIT;
  Journal."Journal Template Name" := 'GENERAL';
  Journal."Journal Batch Name" := 'DEFAULT';
  //Leave Journal."Line No." empty
  //Set other fields
  Journal.INSERT(TRUE);
//End Loop

Obviously the first entry is created properly by the code above - FirstJournal = ("GENERAL","DEFAULT",0) - but it fails to create the second one as it uses the same Line No – SecondJournal = ("GENERAL","DEFAULT",0).

An easy solution to make it work would be to enable the Autoincrement=true property for the field “Line No.” on table “Gen. Journal Line”. Unfortunately, I would like to use the default objects which come from the installation therefore that solution it is not valid for me.

In the other hand, as far as I understand the page 39 – General Journal uses the AutoSplitKey to solve the issue and it generates the Line No dynamically.

Is there any other alternative that I am missing if I do not want to modify the objects which come by default in the NAV installation?

Many thanks!

Best Answer

Answers

Sign In or Register to comment.