web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

Enums and Options in Business Central AL — A Complete Guide

Aman Kakkar Profile Picture Aman Kakkar 236

What Are Options?

Options are the traditional way of defining a fixed list of values in AL. They’re simple, fast, and ideal for static scenarios.

Example:

field(10; "Document Type"; Option)
{
    OptionMembers = Quote, Order, Invoice, CreditMemo;
    OptionCaption = 'Quote,Order,Invoice,Credit Memo';
}

Here:

  • The field can only take one of the four values: Quote, Order, Invoice, or CreditMemo.
  • Each value is stored internally as an integer (0, 1, 2, 3...).
  • OptionCaption property is used to set the Caption for each of the options.

You can use it in your code like this:

if Rec."Document Type" = Rec."Document Type"::Order then;


What Are Enums?

Enums (Enumerations) are the modern replacement for Options, as they can be extended just like pages and tables.

They support extensions, localization, and interfaces, making them ideal for scalable solutions. In the syntax, you will see that what we define in the options with comma separated, we here define them in value.

Example:

enum 50100 "Document Type Enum"
{
    Extensible = true;

    value(0; Quote) { Caption = 'Quote'; }
    value(1; Order) { Caption = 'Order'; }
    value(2; Invoice) { Caption = 'Invoice'; }
    value(3; CreditMemo) { Caption = 'Credit Memo'; }
}
To use enums in table fields - 
field(10; "Document Type"; Enum "Document Type Enum") { }​​​​​​​

ValuesAllowed Property for Enums and Options

We can use the ValuesAllowed property with Enums as well as with Option fields — allowing only specific values to appear in a given context.

Example:

field(20; "Document Type Restricted"; Enum "Document Type Enum")
{
    ValuesAllowed = Quote, Order; // Only Quote and Order allowed
}
  • It gives you context-based control without changing the definition itself.
  • Keeps your code cleaner and extensible.


Extending Enums

The real power of Enums is that they can be extended:

enumextension 50101 "Document Type Ext" extends "Document Type Enum"
{
    value(4; ReturnOrder)
    {
        Caption = 'Return Order';
    }
}


Best Practice

  • Use Enums for all new development.
  • Use Options only for legacy or static logic.
  • Use ValuesAllowed to control which Enum/Option values users can select on specific pages.
  • Mark Enums as Extensible = true when you expect them to grow.
  • Always define Captions for multilingual support.

Conclusion


Both Enums and Options let you define lists of fixed values — but Enums are the future of extensibility in Business Central. With properties like Extensible, ValuesAllowed, and ObsoleteState, Enums give you flexibility, clarity, and upgrade safety — all while keeping your code structured and maintainable.

Comments