I have an option field in a custom table taking the following values: ,1a,1b,1c,1d,2,3e,3f,3g,3h,3i,4
When I filter on it in the corresponding page, I get strange results:
Filter on "1a" --> correct results Filter on "1b" --> entries with "2" Filter on "1c" --> correct results Filter on "1d" --> entries with "4" Filter on "2" --> correct results Filter on "3e" --> correct results Filter on "3f" --> correct results Filter on "3g" --> correct results Filter on "3h" --> correct results Filter on "3i" --> correct results Filter on "4" --> error message : '21' is not an option.The existing options are ,1a,1b,1c,1d,2,3e,3f,3g,3h,3i,4
(21 is the index of “4” in the option string)
I can’t understand why it is working for some values and not for the rest…Any ideas?
You should also know how the option fields really work, unless you know it already.
Internally in SQL there is no such thing as an option field. When the data is stored in the database, it only contains the number it has on the option list, starting with 0. So if you’re setting filters from the code, then all you need is really an integer value to set the filter.
Like SETRANGE(“Option Field”,1); You can also write it like SETRANGE(“Option Field”,“Option Field”::“1”); - then when compiling the code, it will “translate” the “1” to the text used in the option setting.
Remember that you must also be 100% sure that both the actual option value string and the option caption ML strings are synchronized. If you somehow have forgotten to update the Option Captions, after you changed the actual options, then it will give you problems.
If you have no code to show, then please show a screen shot of how you are setting the filters in the page. After you have checked the option captions.