Enums [AX 2012]
Updated: September 21, 2011
Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
X++ does not support constants but has an enumerable type (enum), which is a list of literals. You need to create an enum in the Application Object Tree (AOT) before you can use it.
Enum values are represented internally as integers. The first literal has number 0, the next has number 1, the next has number 2, and so on. You can use enums as integers in expressions.
There are hundreds of enumerable types that are built into the standard application. For example, the enum NoYes has two associated literals, where No has the value 0, and Yes has the value 1.
To get a list of all enums when you are using the X++ code editor, press F11.
To create an enum
Expand the Data Dictionary node in the AOT.
Right click the Base Enums node and select New Base Enum.
Rename the enum.
The literals in the enum are called elements. Right-click the enum and select New Element.
Rename the element.
Add as many additional elements as you need.
By default, elements take values in the order in which they are created. The first element has the value 0, the second element has the value 1, and so on. However, you can explicitly assign a particular integer value to an element by using the EnumValue property.
Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.