You may or may not have noticed that Business Central is phasing out the Option field and replacing it with enums which stands for enumeration list. This will allow the fields to be easily extended in the future. I’ll walk you through how to create a new enum then add a new enum field to an existing table.
The first step is to create an enum object and define the list of options for the enum. For this example, I’ll add a new field to the item card called “Finish” and create an enum for this field with the options Smooth, Sanded, Primed, Unfinished.
The code below defines this new enum.
Now we need to add the new field to the Item table and set it as type enum of Finish.
Next, we need to add the field to the page, I’ll add it under the Item tab on the Item Card.
So now let’s take a look at the Item Card and see what our new field looks like.
As you can see we now have a new field on the Item Card called Finished which has the options Smooth, Sanded, Primed, and Unfinished.
The other thing we can do with Enums is to extend enums in base objects. A good example of this is extending the Type field on the Sales Line, which is now an Enum of type “Sales Line Type”, looking at the definition of this enum it has 6 options. The definition is below:
So we want to extend this base definition and add a new option called “Sample”. To do this we create an enum extension and add our new option.
Now we can take a look at the Sales Order, we are now able to select a Type of “Sample”.
Once we have the new Sample type on the Sales Line we can use subscriptions to add further functionality to this new Sales Line Type.