Is there somthing wrong with EVALUATE...?

voodoo
Member Posts: 82
Hi, I have some problem with this part of my code:
StatusValue is global variable, type Option;
ValueArray is type of text
Something is wrong with EVALUATE, because if I put only EVALUATE(StatusValue,ValueArray[1]) I have a messagebox:
You cannot enter 'Status::Released' in Option.
:-k
Thnx
IF EVALUATE(StatusValue,ValueArray[1]) THEN BEGIN SETRANGE(Status,StatusValue); END
StatusValue is global variable, type Option;
ValueArray is type of text
Something is wrong with EVALUATE, because if I put only EVALUATE(StatusValue,ValueArray[1]) I have a messagebox:
You cannot enter 'Status::Released' in Option.
:-k
Thnx
misha fka voodoo
0
Comments
-
-
Like I said: Status::Released
It's the value from the field of my table UserFilter(field type is Text)
Thnxmisha fka voodoo0 -
Have you tried setfilter instead of setrange?
Setrange expects the same datatype as the field, setfilter accepts strings.
You might have to remove the Status:: from the string.0 -
Mark Brummel wrote:You might have to remove the Status:: from the string.
This is the source of the problems... :-)
And do not forget, that you will have problems when you switch your language...0 -
To elaborate...
You are right in using EVALUATE for this purpose, but you're going about it incorrectly. Syntax like 'Status::Released' is the C/AL code way to designate an option value. Internally, the database stores it as an integer (so you could even just set the filter on the integer value if you know which value that is). The text representation of the option value is just the word that belogns to the option, in your case that would be 'Released'.
So, try setting your array value to 'Released' and see if that works.0 -
Mark Brummel wrote:Have you tried setfilter instead of setrange?
Setrange expects the same datatype as the field, setfilter accepts strings.
You might have to remove the Status:: from the string.misha fka voodoo0 -
The EVALUATE function is created to do things no other statement can do and basicly acts as if a user enters a field.
I don't think you have to use the evaluate function in this case. If the string in the user setup table is correct you should only have to make something like
SETFILTER(Optionfield, UserSetup.Optiontext);
Just make sure the text value in the usersetup has the right syntax.0 -
Mark Brummel wrote:The EVALUATE function is created to do things no other statement can do and basicly acts as if a user enters a field.
I don't think you have to use the evaluate function in this case. If the string in the user setup table is correct you should only have to make something like
SETFILTER(Optionfield, UserSetup.Optiontext);
Just make sure the text value in the usersetup has the right syntax.
OK, let me explain, in Sales Header table, Status field is type of Option, and if I want to do this:
SETFILTER(Status, MyTable.Optiontext);
I will get an error in compile time: Type conversion is not possible because...
Option := Text
and I must do EVALUATE, right!?
mishamisha fka voodoo0 -
Using SETFILTER you can use a string to set the filter, even if the table field has another datatype.
I think you are getting SETFILTER and SETRANGE mixed up :?
Have you tried it??
Make a small test:SalesHdr.SETFILTER("Document Type", 'Order'); form.run(0, SalesHdr);
0 -
Mark, thnx it's working :oops:
But, another problem is when I switch between languages, because, optionstring is text and it's value depend from chosen laguage........example:
Status::Released (in english) <-> Status::Lansiran (in serbian)misha fka voodoo0 -
Yes, this is the general problem with these type of filtering.
A workaround can be to work with numbers or to just write some more code.
You can also replace the text field in the user settings by an option string.
Do you want to filter on one option only or do you want to set multiple filters like "Quote|Order"??0 -
-
-
-
-
-
-
-
-
-
Mark Brummel wrote:Yes, this is the general problem with these type of filtering.
A workaround can be to work with numbers or to just write some more code.
You can also replace the text field in the user settings by an option string.
Do you want to filter on one option only or do you want to set multiple filters like "Quote|Order"??
One option only....misha fka voodoo0 -
In this case you can also change your text filter in the user setup to an option field, then you won't have problems with the multilanguage thing.
Sorry for highjacking your topic :oops: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