Fieldref Code field to Variant
fhoog
Member Posts: 5
In the following code I open the ‘Vendor’ table (23) and read the first field ‘No.’ (Data Type ‘Code 20’).
Locals:
lVarValue Variant
lRrfTable RecordRef
lFrfField FieldRef
Code
lRrfTable.OPEN(23);
lRrfTable.FINDFIRST;
lFrfField := lRrfTable.FIELD(1);
lVarValue := lFrfField.VALUE;
MESSAGE('Result:%1',lVarValue);
Assume the value of the first field in the first record of table 23 is '10000' then the result of this function is 10000 with a square before it.
Does anyone have a solution to this?
I already tried lVarValue := FORMAT(lFrfField.VALUE), which works fine, but it is not preferable for other datatypes.
Locals:
lVarValue Variant
lRrfTable RecordRef
lFrfField FieldRef
Code
lRrfTable.OPEN(23);
lRrfTable.FINDFIRST;
lFrfField := lRrfTable.FIELD(1);
lVarValue := lFrfField.VALUE;
MESSAGE('Result:%1',lVarValue);
Assume the value of the first field in the first record of table 23 is '10000' then the result of this function is 10000 with a square before it.
Does anyone have a solution to this?
I already tried lVarValue := FORMAT(lFrfField.VALUE), which works fine, but it is not preferable for other datatypes.
0
Comments
-
I would suggest using case statement and handle each datatype differently
lRrfTable.OPEN(23); lRrfTable.FINDFIRST; lFrfField := lRrfTable.FIELD(1); FieldType := format(lFrfField.TYPE); case FieldType of 'Code': CodeValue := lFrfField.VALUE; 'Integer':; end; MESSAGE('Result:%1',CodeValue);0 -
Actually I want to write a function to read a value of a given table number and field number. This function would need to have too many parameters (e.g. for every possible data type a different one).
Now I am going to try an other solution where code is always converted to text. Of course does code then always show up as text in the variant, but in my case that's no problem.
IF FORMAT(lFrfField.TYPE) = 'Code'
THEN vVarValue := FORMAT(lFrfField.VALUE)
ELSE vVarValue := lFrfField.VALUE;
I hope other data types don't have similar problems.0 -
By the way, the problem of the added square only arises if the field (of data type Code) contains a value. If it's partially text no problem occurs.0
-
I don't know why it would add the extra character, which looks like carriage return0
-
I read the value of the first character and it seems to be the length of the string.0
-
Interesting. :-k0
-
Could be. In Navision, strings as stored with the length in the first character (Like Pascal) and not null-terminated (like C).fhoog wrote:I read the value of the first character and it seems to be the length of the string.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
