In this video, I demonstrate how you can “upgrade” your Option fields to Enums in Microsoft Dynamics 365 Business Central. I show how to can get rid of some of the bad patterns we have accepted with option fields.
Let’s start with what exactly the Business Central ENUM is. Those who come from an object-oriented programming background might already know what the enums are. enums are objects that are essentially a read-only list of items. Another change with the Business Central is that lists begin with the number 0. It goes for Business Central enums as well, so you can refer to specific items both by name and number. If you want to choose the first element, then type in 0 or the element’s name.
To define a variable of type Option, you can’t use the OptionMembers property that’s used on a field of data type Option. You need to list the available options as a comma-separated list after your variable definition.
For example:- Color: Option Red,Green,Yellow;
During my AL training classes, a frequently asked question is how to convert enum values to and from integer or text. So I thought it would be a good idea to share with you what possibilities you have.
First of all, we need to understand the properties of an enum. Let’s look at an enum definition and see how it is constructed.