{"title":"Option data type","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/option/option-data-type/","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/methods-auto/option/option-data-type, 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/methods-auto/option/option-data-type","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":"Denotes an option value.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax example","slug":"syntax-example","at":162,"chars":370},{"level":2,"title":"Remarks","slug":"remarks","at":532,"chars":363},{"level":2,"title":"Example 1","slug":"example-1","at":895,"chars":353},{"level":2,"title":"Example 2","slug":"example-2","at":1248,"chars":193},{"level":2,"title":"Related information","slug":"related-information","at":1441,"chars":117}],"text":"> Version: _Available or changed with runtime version 1.0._\nDenotes an option value. In the code snippet below, you can see how the Option data type is declared.\n## Syntax example\n```al\nprocedure HelloWithOptions(OptionParameter : Option Alpha, \"Bra-vo\")\n    var\n        OptionVariable : Option C, \"or D\";\n    begin\n        Message('%1',OptionParameter::Alpha);\n        Message('%1',OptionVariable::C);\n    end;\n```\n> NOTE\n> It is not possible to reference the members of the OptionParameter from outside the body of the procedure.\n## Remarks\nIn the OptionString Property<../../properties/devenv-optionmembers-field-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.\n## Example 1\nThe following code sample shows how to define an option field in a table.\n```al\nfield(0; PreferredContactMethodCode; Option)\n{\n    Caption = 'Preferred Method of Contact';\n    // The OptionMembers property must be defined on an option field. It specifies which values can the field take.\n    OptionMembers = Any,Email,Phone,Fax,Mail;\n}\n```\n## Example 2\nThis example shows how you can use the value of an option field as a constant in your AL code.\n```al\nPurchHeaderRec.\"Document Type\" := PurchHeaderRec.\"Document Type\"::Invoice;\n```\n## Related information\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}