(DEV) What's wrong with the type conversion?
redhotmustang
Member Posts: 91
Hi,
Please explain me.
I have an integer variable that receives the result of the getfilter function.
This year field is of the same data type of the var variable: integer.
But the system says "type conversion is not possible, integer := text". But the year field is an integer.
Later on, I need to add 1 to that value: year + 1. And this error will appear again. I read the evaluate function but I did not understand it.
How can I solve this?
Thanks in advance.
Please explain me.
I have an integer variable that receives the result of the getfilter function.
var := table.GETFILTER(year);
This year field is of the same data type of the var variable: integer.
But the system says "type conversion is not possible, integer := text". But the year field is an integer.
Later on, I need to add 1 to that value: year + 1. And this error will appear again. I read the evaluate function but I did not understand it.
How can I solve this?
Thanks in advance.
Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)
0
Answers
-
i think it's
var := table."year";
0 -
No, that does not work.Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)0
-
The GETFILTER ALWAYS returns a string, so you have to do this:
EVALUATE(var,table.GETFILTER(year));
Of course this means that the filter on year must filter ONLY 1 VALUE otherwise you will have an error anyway.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
The filter on year must return 2006, but lots of records for that year. So that didn't work.
But I understood how the evaluate function works and solved the problem.VarYear := table.GETFILTER(year); EVALUATE(MyVar,VarYear);
It works like this:
The result of the getfilter function is contained in the code data type variable "VarYear", although the "year" field is an integer.
"MyVar" is an integer data type variable.
Then, the evaluate function places the value of the "VarYear" variable in the "MyVar" variable, transforming the value of the code data type variable "VarYear" into an integer value in the "MyVar" variable.
Making it possible to add 1 to "MyVar" value.
I think this is it.
Thank you.Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)0 -
You should always have an error trap on evaluate imo...
IF NOT EVALUATE(MyVar,table.GETFILTER(year)) THEN ERROR('your error here');
(Like kriki was saying, the filter on year could have a range: '01/01/08..02/02/08' and would throw an error on your evaluate)0 -
Xypher wrote:(Like kriki was saying, the filter on year could have a range: '01/01/08..02/02/08' and would throw an error on your evaluate)
Yes, I got that after posting my reply, that is not lots of records, but more than one value for that filter.
That error trap is it still necessary if the one data item's ReqFilterFields is that year field? I mean if we don't filled it in the report won't run, or it won't do anything. I'm just correcting this report, and I could change it to include this error trap, but I ended up using a variable being evaluated in another situation.Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)0 -
Somewhere the filter gets set and I'd try and catch that value there instead of trying to retrieve it from the filter. There are two other filterfunctions you can try to use for individual values, which are the GETRANGEMIN and GETRANGEMAX functions, look it up in the C/SIDE reference guide for more details. You also don't have to put the return value into a separate variable, you can go straight into the integer:
IF EVALUATE(SomeIntegerVariable,Table.GETRANGEMIN(Field)) THEN MESSAGE('evaluated the lowest value in the filter') ELSE MESSAGE('could not evaluate the value');This is assuming that the field holds an integer type value. If it holds a date value, you'd have to use one of the date functions to get the integer representation of any of the elements of the date.0 -
Thanks that's really helful. I'll read more about it in C/SIDE reference guide.Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)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
- 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
