TESTFIELD failure
vaprog
Member Posts: 1,173
I'm in the process of porting some code from NAV 2009 R2 to NAV 2013 R2. The following line of code worked in 2009, but trows a peculiar error on 2013 R2:
Has anybody any clue as to what might be wrong?
WITH ParameterSpec DO BEGIN
...
TESTFIELD("Parameter Type","Parameter Type"::Integer);
Definition of field Parameter Type:Microsoft Dynamics NAV
Break On Error Message:
Parameter Type must be equal to 'Integer' in Parameter Spec.: Code=TEST2, Line No.=10000. Current value is 'Integer'.
OK
{ 12 ; ;Parameter Type ;Option ;OptionString=[ ,Integer,Decimal,Code,Text,Date,DateFormula,TableFilter,Boolean] }
The debugger says, the value is Integer just before the error is thrown.Has anybody any clue as to what might be wrong?
0
Answers
-
see the bottom example here:
http://msdn.microsoft.com/en-us/library/dd301274.aspx
Seems to be what you are experiencing.
What are you trying to do with code?
Only process something that has an integer parameter?0 -
Either you have an error with a local variable named like a global variable, a local variable named "Parameter Type", or the debugger is messing with you (as so often before...).
This code will work for sure - always!:SomeTable.OptionField := SomeTable.OptionField::Integer; SomeTable.TESTFIELD(OptionField, SomeTable.OptionField::Integer);
1 Go through local/global variables.
2 Skip the WITH ParameterSpec DO BEGIN line and add the tablevariable where neccessary.
3 Insert a line like:IF CONFIRM('%1', TRUE, FORMAT(ParameterSpec."Parameter Type", 0, '<Text>')) THENjust before the TESTFIELD line.
4 Try to isolate the problem in a new simple table with just a few fields of the appropriate type.0 -
Thanks for your suggestions.
I first added the record var explicitly in the code (but left the WITH in place. It must have no effect on that changed line of code, thoughParameterSpec.TESTFIELD("Parameter Type",ParameterSpec."Parameter Type"::Integer);This did not help.
I then added aIF ParameterSpec."Parameter Type" <> ParameterSpec."Parameter Type"::Integer THEN
just in front of the TESTFIELD, which also did not bring about any change, which really made me wonder.
I then noticed the field "Parameter Type" is a FlowField of Lookup type (CALCFIELDS was executed on it). However, the OptionSting value of the two fields differed. So, apparently, :bug: NAV used the OptionString definition of the table looked up from to show the value in the debugger and for the field value in the error message. The option constant, though was taken from the FlowField itself :roll:.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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 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