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
0
Comments
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").
Try this code below
IF Customer.Blocked <>0
THEN block := text1;
Regards
MAJB
=D>
Thanks again.
Using FORMAT will dispaly the option string value instead of the integer.
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...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.