Is there any way to iterate through all possible values of an option field? Let's suppose I have a table with an option field called MyField that can take the following OptionString 'Red,Green,Blue,Yellow'
I'd like to write some C/AL code, completely agnostic about the possible values. I do not want to know if there are only 4 or 40 options. Any way of knowing the upper boundary?
Writing something like:
FOR var := MyTable.MyField::Red TO MyTable.MyField::Yellow DO
...
would imply that you know the possible values.
Is there any way to write this without having to hard code them in advance. I mean, any way that would not need to be rewritten, if the optional values are ever modified (added new values for instance).
Thanks in advance.
0
Answers
I haven't tried to do what you want to do, but I quess if you try something like this: I'm definitly not sure about the format check, but I believe that when formatting the optionvalue, you receive the selected optionstring, and if else just the number or empty
|To-Increase|
Regards.
You should be able to structure your code in a CASE statement, and if later there is an actual business need to add a new option, then you add to the CASE. Colors are NOT a case where you would use an option, except if the colors are representative of something that is not a color. Say for example on Resistors where the color (Black,Brown, Red,Orange,Yellow,Green etc) represent the value in Ohms of the resistor (1,1.2,1.5,1.8,2.2 etc) those values are fixed and don't change. But in the case of the color of a Tee Shirt, the manufacturer could add more colors so don't use an option.
The solution is the fix the problem at the source, not finding hacks to work around a bad design.
Where is the LIKE button?
The option is available in "Report this Post" button with Font Red "!" sign.
http://ssdynamics.co.in