Description:-
However, if you only need a fixed number of categories or the application users are not able to define the categories, you can use a base enum, such as Item type, used for defining the type for inventory items.
Base
Enums come in handy for categorizing data. One way of categorizing is to create
a related table, such as item groups, which is used for grouping inventory
items.
However, if you only need a fixed number of categories or the application users are not able to define the categories, you can use a base enum, such as Item type, used for defining the type for inventory items.
- A base enum can have a maximum of 255 entries. A good example for multiple enteries in a base enum is LedgerTransTxt. But in general there will be very few entries.
- The value of a base enum is stored in the database as an integer value. Entry values starts by default from zero and are consecutively numbered. The property EnumValue will show you the number stored in the database for an entry.
- We can also manually enter a particular number for an entry in base enum, this can be done if the base enum property UseEnumValues is set to Yes.
- System enums are located in the AOT under System Documentation/Enums, an example for system enum is ‘TableGroup’ represents the entries of the table property TableGroup.
- To refer to a base enums entry in code, the name of the base enum is entered followed by a double colon. By pressing the second colon lookup will show the available entries.
static void RetreiveEnumValue(Args _args) { DictEnum denum; A_StudentDemoTable A_StudentDemoTable; int i; //How to Check Values in Enums denum=new DictEnum(enumName2Id("StudentResult")); info("-----------Enum Values-------------"); for(i=0;i<denum.values();i++) { info(strFmt("%1 - %2",denum.index2Label(i),denum.index2Value(i))); } //How to Use Enum info("--------------------------------------"); info("-----------Student Results-----------"); while select * from A_StudentDemoTable where A_StudentDemoTable.Result == StudentResult::FAIL { if(A_StudentDemoTable.Result) { info(strFmt("StudentID - %1, Result - %2",A_StudentDemoTable.Student_ID,A_StudentDemoTable.Result)); } } info("--------------------------------------"); }
We could also use the base enum entry numbers instead, but it
would make your code more difficult to read and maintain.
Note: The first entry of a base enum normally has
the value zero - which will return false, if the first entry is validated in an
if-expression. This is also the reason why fields of the type enum should not
be mandatory as the first entry of an enum would be considered as not valid.
2 comments
commentsInformative blog. Thanks for sharing.
ReplyDevOps Training
DevOps Online Training
Great Article.. Thank you for sharing..
ReplyD365 Finance and Operations Training
D365 Ax Technical Online Training
D365 Finance and Operations Online Training
Microsoft Dynamics AX Technical Training
Microsoft Dynamics AX Training
Thanks for comments.....