Filter a option field

Leroy
Member Posts: 199
Dear folks, I think this is easy. I'd like to know the condition to get the different result of a field type option. I mean, I want a similar code like this:
IF customer.Blocked=customer.Blocked<>" " THEN block:=text1;
I want that filter all the registers different from empty.
Thanks for help
IF customer.Blocked=customer.Blocked<>" " THEN block:=text1;
I want that filter all the registers different from empty.
Thanks for help
0
Comments
-
IF Blank is the first value in the list:
IF customer.Blocked > 0 THEN block:=text1;
However the statement (block:=text1) may not work. An option field is stored as an integer. It need to be either assigned as an integer (block := 1) or by it's option list (block := block::"option 1").There are no bugs - only undocumented features.0 -
The option field can be referenced by name or by number from 0 to n. Blank is usually referenced as 0.
Try this code below
IF Customer.Blocked <>0
THEN block := text1;
Regards
MAJB0 -
Perfect!!!, Thank you very much for help.
=D>0 -
Sorry, only one question; if I want to show a text if a condition is true, I mean; If blocked is <> 0 then blocked:='Customer blocked". How can I do that if blocked is a option field and the text is text?.
Thanks again.0 -
Textvar := FORMAT(Customer.Blocked );
Using FORMAT will dispaly the option string value instead of the integer.There are no bugs - only undocumented features.0 -
I think that there is good place to mention some rules for using option data type:
1) When possible and you need to use specific option value, use the operator :: - it means something like myOptionVar::"Option 1". You can write it as myOptionVar::"1" and after reopening the object NAV will automatically "expand" the number by correct value.
-easy
-readable
2) When you need to pass some option into some function, you can use integer variable, but use it only with caution and in cases, when you are working only with the variable, not with some specific values (you do not need use "constants" in the code).
3) Never use integer constants instead option constant in the code. Nobody else will know what does it mean. It is not possible to maintain that (e.g. in case when bad things happen like when you need to insert new option into existing one - but this is example of really bad thing).
4) Never, NEVER, use text constant in connection with option value (like myOptionVar := 'Option 1'). This will not work in another language than you wrote it, it will not work when somebody change the caption on the option, simply - It will not work... (with exceptions)
5) You can think about Option as about integer, but only for math operations with the options like comparison, adding, subtracting. But when comparing, use point 1 to compare with specific value...0 -
One other tip:
When adding custom option values, to a standard option field, add a few blank option values after the standard NAV values and before yours. For example, if the base NAV option string is [NAVoption1,NAVoption2,NAVoption3], then make the string [NAVoption1,NAVoption2,NAVoption3,,,,YourNewOption] instead of [NAVoption1,NAVoption2,NAVoption3,YourNewOption]. This way is NAV adds a new option or two, it won't conflict with data from your custom value.There are no bugs - only undocumented features.0 -
Of course, this is example how to precede the possible problems...0
-
Good advices;Thanks both for help.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