Problem inserting: Last row replace.

Guga84
Member Posts: 24
Hi, I’m trying to insert new lines in the "Journal Line Dimension" table, but at least it just inserts the last one, the others are replaced by the last.
I think the primary key is ok in each record, so I don’t know what could be wrong.
Does anybody know why this happens?
Here is a piece of code where I do the insert.
The messages are correct in each loop.
Thanks.
I think the primary key is ok in each record, so I don’t know what could be wrong.
Does anybody know why this happens?
Here is a piece of code where I do the insert.
CLEAR(rJournalLineDimension); rJournalLineDimension.VALIDATE(rJournalLineDimension."Table ID",81); rJournalLineDimension.VALIDATE(rJournalLineDimension."Journal Template Name" , rGenJournalLine."Journal Template Name"); rJournalLineDimension.VALIDATE(rJournalLineDimension."Journal Batch Name", rGenJournalLine."Journal Batch Name"); rJournalLineDimension.VALIDATE(rJournalLineDimension."Journal Line No.", rGenJournalLine."Line No."); rJournalLineDimension.VALIDATE(rJournalLineDimension."Allocation Line No.", 0); rJournalLineDimension.VALIDATE(rJournalLineDimension."Dimension Code", rGeneralLedgerSetup."Shortcut Dimension 3 Code" ); rJournalLineDimension.VALIDATE(rJournalLineDimension."Dimension Value Code",vAuxSD3C); WITH rJournalLineDimension DO BEGIN MESSAGE ('%1,%2,%3,%4,%5,%6,%7',FORMAT ("Table ID"),"Journal Template Name","Journal Batch Name", "Journal Line No.","Allocation Line No.","Dimension Code","Dimension Value Code"); END; IF (rJournalLineDimension.INSERT) THEN MESSAGE('Inserta OK');
The messages are correct in each loop.
Thanks.
0
Answers
-
Well this looks good, except 1 detail:
rJournalLineDimension.VALIDATE(rJournalLineDimension."Table ID",81);
should be:rJournalLineDimension.VALIDATE(rJournalLineDimension."Table ID",DATABASE::"G/L Journal Line");
Never use a number to assign some object-ID to some variable, but always use the option for it.
What is the code for looping?Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
You have a 0 hardcoded as Allocation Line No., shouldn't this increment?0
-
mart1n0 wrote:You have a 0 hardcoded as Allocation Line No., shouldn't this increment?
The primary key should be unique even is this number is always 0, because the "line. No." changes. :shock:
If I follow the standard the "Allocation Number" might be 0, so I can't take this as a chance.
However, if I increment this number, it inserts some dimensions correctly, but not the 1 and 2 dimension. So I think the problem could be here.
The code is for insert new lines in Gen Journal Line, from an Excel sheet.
As the Gen Journal Line only have shortcut for dimensions 1 and 2, I have to insert the others dimensions by code. But the dimension 1 and 2 are not correctly inserted, so
¿Does anybody know if in Navision Attain the dimension 1 and 2 are automatically inserted in the "Journal line dimension " table when you validate a journal line?
Thanks0 -
Guga84 wrote:¿Does anybody know if in Navision Attain the dimension 1 and 2 are automatically inserted in the "Journal line dimension " table when you validate a journal line?
You need to leave the "Line No." = 0 and use VALIDATE("Shortcut Dimension 1/2 Code",'Some value');. This saves the data in globals in the record-variable of table 81 until you do a INSERT(TRUE);
And remember : just BEFORE doing the INSERT(TRUE), you need to change the "Line No.".
PS : If you assign a number to "Line No." before doing the validates, this will save the dimensions directly to the table, BEFORE you do the INSERT(TRUE). Best is to do all at the same moment.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
At the end, I insert the lines with Allocation Line No different to 0 and after the insert I modify the "Allocation Line No" to 0. It's not the best solution but it works.0
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