<img alt="" src="https://secure.intelligent-consortium.com/791393.png" style="display:none;">

Introduction to Developing Enums in Business Central

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.

Enums

Now we need to add the new field to the Item table and set it as type enum of Finish.

Enums

Next, we need to add the field to the page, I’ll add it under the Item tab on the Item Card.

enumeration list

So now let’s take a look at the Item Card and see what our new field looks like.

enumeration list

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:

enumeration list

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.

enumeration list

Now we can take a look at the Sales Order, we are now able to select a Type of “Sample”.

enums

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.

 

Click Below to See the Webinar Introduction to Developing Enums in Business Central

Register Now

Rick Folkner

Rick Folkner

Rick works on the Development Team at Innovia. He has been working with Dynamics NAV since 2007, starting with version 4.0. He's done development work in many areas of NAV, including Financials, Sales & Marketing, Purchasing, and Warehouse.

Related Posts