{"title":"Extensible Enums","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-extensible-enums/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-extensible-enums, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-extensible-enums","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Overview of the enumeration type and the concept of extending them.","date":"2025-05-21","meta":{"topic":"concept-article"},"outline":[{"level":2,"title":"Enumextension object","slug":"enumextension-object","at":2501,"chars":396},{"level":2,"title":"Usage","slug":"usage","at":2897,"chars":596},{"level":2,"title":"Example","slug":"example","at":3493,"chars":1564},{"level":3,"title":"Conversions","slug":"conversions","at":4736,"chars":321},{"level":2,"title":"Related information","slug":"related-information","at":5057,"chars":221}],"text":"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.\nTo declare an enum in AL, you must specify an ID and a name. The enumeration list consists of values and each of the values are declared with an ID and a value. The value ID is the ordinal value on the enumeration list and must be unique. When the enum values are displayed in the UI, they're sorted by the order of declaration. In addition, if extension B extends extension A, the enum values declared in extension A are displayed before the enum values declared in extension B.\nThe following example shows the declaration of an enum, which can be extended, and has the four values; None, Bronze, Silver, and Gold.\n> IMPORTANT\n> Only enums with the properties/devenv-extensible-property set to true can be extended.\n```al\nenum 50121 Loyalty\n{\n    Extensible = true;\n\n    value(0; None) { }\n    value(1; Bronze) { }\n    value(2; Silver) { }\n    value(3; Gold)\n    {\n        Caption = 'Gold Customer';\n    }\n}\n```\n> NOTE\n> While enums and enumextension objects have object IDs, these aren't enforced by the license. In previous versions they reused the range for tables, and were checked against the license at deployment time, but this is no longer the case. Uniqueness validation is now enforced during installation, which will fail if an enum object ID clashes with an already installed enum. Thus, as always, it's important that you use object IDs in your assigned range. This is enforced for Marketplace apps, but not for per-tenant extensions, or on-premises. The enum doesn't have to use the same ID as the table it's put on.\n> With Business Central 2023 release wave 1, IntelliSense suggests the next available enum ordinal value both when creating new enums, or when extending existing enums.\n> IMPORTANT\n> When creating captions for enums, it's important that the caption doesn't contain a comma. Having a comma in the caption, such as `Caption = 'Diamond Level, with bonus'`, can display over multiple lines in the UI. This behavior also causes that the actual value selected by the user in the UI, doesn't correspond to the value, which is saved in the database.\n> An AppSourceCop warning is triggered if .xlf files contain commas in enum captions. See AppSourceCop Warning AS0087<analyzers/appsourcecop-as0087>.\n## Enumextension object\nEnums can be extended to add more values to the enumeration list in which case the Extensible property must be set to true. The syntax for an enum extension, which extends the Loyalty enum with the value Diamond, is shown below.\n```al\nenumextension 50130 LoyaltyWithDiamonds extends Loyalty\n{\n    value(50130; Diamond)\n    {\n        Caption = 'Diamond Level';\n    }\n}\n```\n## Usage\nWhen referencing a defined enum from code, you use the syntax as illustrated below.\n`enum Loyalty`\nIf you want to define an enum as a table field type, use the syntax illustrated below:\n```al\nfield(50100; Loyal; enum Loyalty) {}\n```\nOr, as a variable:\n```al\nvar\n    LoyaltyLevel: enum Loyalty;\n```\nIn code, you address a specific enum value like in the following example:\n```al\ncodeunit 50140 EnumUsage\n{\n    procedure Foo(p: enum Loyalty)\n    var\n        LoyaltyLevel: enum Loyalty;\n    begin\n        if p = p::Gold then begin\n            LoyaltyLevel := p;\n        end;\n    end;\n}\n```\n## Example\nThe following example illustrates how to define an enum extension of TypeEnum, using it in a table extension TableWithRelationExt and displaying it as a control on a new page.\n```al\nenumextension 50133 TypeEnumExt extends TypeEnum\n{\n    value(10; Resource) { }\n}\n\ntableextension 50135 TableWithRelationExt extends TableWithRelation\n{\n    fields\n    {\n        modify(Relation)\n        {\n            TableRelation = if (Type = const (Resource)) Resource;\n        }\n    }\n}\n\npage 50133 PageOnRelationTable\n{\n    SourceTable = TableWithRelation;\n    SourceTableView = where (Type = const (Resource));\n    PageType = List;\n\n    layout\n    {\n        area(Content)\n        {\n            repeater(MyRep)\n            {\n                field(Id; Id)\n                {\n                    ApplicationArea = All;\n                }\n                field(Type; Type)\n                {\n                    ApplicationArea = All;\n                }\n                field(Relation; Relation)\n                {\n                    ApplicationArea = All;\n                }\n            }\n        }\n    }\n}\n```\n> TIP\n> For another example of how to extend the usage of the TableRelation property with enums, see properties/devenv-tablerelation-property.\n### Conversions\nConversion to and from enum is more strict than for Options in C/SIDE.\n An enum can be assigned/compared to an enum of the same type.\n To be backwards compatible, we support conversion to/from any Option for now.\nLearn about assignment compatibility in properties/devenv-assignmentcompatibility-property.\n## Related information\nAL data types<methods-auto/library>\nproperties/devenv-tablerelation-property\nproperties/devenv-extensible-property\nmethods-auto/enum/enum-data-type\nproperties/devenv-assignmentcompatibility-property"}