Error in Navision 360 fieldref

MarkW
Member Posts: 6
I have discovered an error when using fieldref’s in a 360 database. Observe the following code:
l_RecordRef.OPEN(DATABASE::TestCountry);
l_RecordRef.INIT;
l_FieldRef := l_RecordRef.FIELD(1);
l_FieldRef.VALUE := 'dk';
l_FieldRef := l_RecordRef.FIELD(2);
l_FieldRef.VALUE := 'Denmark';
l_RecordRef.INSERT;
l_RecordRef.INIT;
l_FieldRef := l_RecordRef.FIELD(1);
l_CodeVar := 'uk';
l_FieldRef.VALUE := l_CodeVar;
l_FieldRef := l_RecordRef.FIELD(2);
l_FieldRef.VALUE := 'United Kingdom';
l_RecordRef.INSERT;
The table “TestCountry” consists of 2 fields, field1 is a “Code 10” and field 2 is a “Text 30”.
When the first insert occurs, then value inserted in the “Code 10” field should have been “dk” but only “k” is inserted. The “d” is somehow removed, which leaves us with incorrect data. Furthermore, a lowercase value has now been inserted in a “code” field causing a “database structure error 1204 in module 19” (Corrupted data). When executing the code, no runtime errors occurs, you have to run a database test, or a backup, to see the error.
If you on the other hand take a look at the 2nd insert, the lowercase value “uk” is assigned to a local variable of the type “Code 10”, the “uk” is therefore changed to “UK” so no errors occurs here.
I can only produce this error in a 3.60 database, but a word of warning: Creating this code in a 3.70 database and importing the object in a 3.60 database causes the same error, even thou the code works fine in a 3.70 database, where the error seams to have been corrected.
Hope some of you can use this…
Regards
Mark Westergaard
l_RecordRef.OPEN(DATABASE::TestCountry);
l_RecordRef.INIT;
l_FieldRef := l_RecordRef.FIELD(1);
l_FieldRef.VALUE := 'dk';
l_FieldRef := l_RecordRef.FIELD(2);
l_FieldRef.VALUE := 'Denmark';
l_RecordRef.INSERT;
l_RecordRef.INIT;
l_FieldRef := l_RecordRef.FIELD(1);
l_CodeVar := 'uk';
l_FieldRef.VALUE := l_CodeVar;
l_FieldRef := l_RecordRef.FIELD(2);
l_FieldRef.VALUE := 'United Kingdom';
l_RecordRef.INSERT;
The table “TestCountry” consists of 2 fields, field1 is a “Code 10” and field 2 is a “Text 30”.
When the first insert occurs, then value inserted in the “Code 10” field should have been “dk” but only “k” is inserted. The “d” is somehow removed, which leaves us with incorrect data. Furthermore, a lowercase value has now been inserted in a “code” field causing a “database structure error 1204 in module 19” (Corrupted data). When executing the code, no runtime errors occurs, you have to run a database test, or a backup, to see the error.
If you on the other hand take a look at the 2nd insert, the lowercase value “uk” is assigned to a local variable of the type “Code 10”, the “uk” is therefore changed to “UK” so no errors occurs here.
I can only produce this error in a 3.60 database, but a word of warning: Creating this code in a 3.70 database and importing the object in a 3.60 database causes the same error, even thou the code works fine in a 3.70 database, where the error seams to have been corrected.
Hope some of you can use this…
Regards
Mark Westergaard
0
Comments
-
There is another bug in 3.60 with recordreferences:
when you assign a decimal to a decimal fieldreference, it is always truncated to 4 decimals.
Best way to avoid both: do a client upgrade.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Hi Kriki
I tried assigning a text directly to a decimal field, this also causes a database structure error. Spooky that no runtime errors occurs here.0 -
It is not recommanded to use RecordRef and FieldRef on NAV 3.60. First stable version is 3.70B or 4.00+.0
-
whew....this last point helped. I thought I was losing my mind! Code I tested in a 3.70B database was working fine but when the objects were imported into a 3.60 DB they were causing unhandled exceptions (i.e. my visual studio debugger tried to trap them).
It's always fun to go back to older DB versions :?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