Base enums and element properties

Completed

A base enum is a list of literals with an assigned value. You will need to create base enumerations in Visual Studio before you can use them in X++ code. Enum values are represented internally as integers, and they are stored in the database as a number instead of the value, which is useful because it saves space. The first literal has the number 0, the next has the number 1, and so on.

Enums can be used as integers in expressions when you are writing code. Each literal or enumeration is assigned a text value through a label and name property. That property is displayed to users in the finance and operations user interface. The system automatically displays this conversion in the user interface, so no more programming is required on the forms that display to the user.

The following screenshot shows how to add a base enum to your project in the Solution Explorer window.

Screenshot showing how to add a base enum to your project in the Solution Explorer window.

Examples

Many enumerable types are built into the standard finance and operations apps. Each enum has various properties that control the appearance and function of the base enum.

For example, the enum NoYes has two associated literals, where No has the value 0, and Yes has the value 1. Typically, this type of enumeration appears as a selectable option in the finance and operations user interface. This is also referred to as the Boolean primitive data type.

A base enum can also appear as a drop-down menu in the user interface, where a user is presented a list of options and one can be selected from the list.

A base enum can be displayed as various buttons. When each button is selected, the user interface updates with new values or information that is related to the selected button.

Properties and elements

Defining properties for a base enum allows you to modify the look of the base enum in the finance and operations apps user interface. While the process of adding a base enum to a project is constant, you can adjust the display length, style, label, and behaviors of the enum by using the Properties window.

Elements that are added to a base enum are stored in the database as a numeric value. The first element that you add is stored as the value 0, the next element is stored as the value 1, and so on. You can use these numeric values as integers when writing X++ code. To give the numeric value a meaningful display name in the user interface, you will edit the Label property in the Properties window.