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

jeqdev
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:
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!
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!
0
Best Answer
-
You can assign line no. using below lines in your code -
OldJournal.RESET;
OldJournal.SETRANGE("Journal Template Name" ,'GENERAL');
OldJournal.SETRANGE("Journal Batch Name",'DEFAULT');
IF OldJournal.FINDLAST THEN
Journal."Line No." := OldJournal."Line No." + 10000;
ELSE
Journal."Line No." := 10000;5
Answers
-
what exactly is your requirement?0
-
You can assign line no. using below lines in your code -
OldJournal.RESET;
OldJournal.SETRANGE("Journal Template Name" ,'GENERAL');
OldJournal.SETRANGE("Journal Batch Name",'DEFAULT');
IF OldJournal.FINDLAST THEN
Journal."Line No." := OldJournal."Line No." + 10000;
ELSE
Journal."Line No." := 10000;5
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions