Business Central : enum vs Options

Posted by

With the release of Business Central 2020 Wave 1 lot of new features has been added to make product more prominent.

Though this concept of ENUM was introduced earlier but from new version onwards most of the option fields are available as extensible enum such as follows that means option fields goes away from table.

Based on few queries received thought lets write down few difference between enum and option.

EnumOption
An enumeration type, also known as an enum in programming, is a keyword used to declare a type that consists of a set of named constants. The list of named constants is called the enumeration list. Enums can be used as table fields, local and global variables, and parameters.In the OptionString Property of the field or variable, you can enter the option values as a comma-separated list. The Option type is a zero-based enumerator type, which means that the option values are assigned to sequential numbers, starting with 0. You can convert option data types to integers.
To declare an enum in AL you must specify an ID and nameTo define option need to add value as comma-seprated list
Enum with extensible property set to true can be extendedTo extend option value need to modify the base table and add the required value
How to define enum
enum 50110 MyList
{
    Extensible = true;
   
    value(0; None) { }
    value(1; First) { }
    value(2; Second) { }
    value(3; Third)
    {
        Caption = ‘My List’;
    }
}
How to define option
field(2; OptionField; option)
{
    OptionMembers = “Option with “, “spaces and “, “other symbols!”;
}

To extend the standard enum from base product visit here

Stay tune for more..

2 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.