bcquality/microsoft/knowledge/interfaces/handle-unknown-enum-ordinals-with-unknownvalueimplementation.md
Jesper Schulz-Wedde 2b5550c346
Some checks failed
Validate knowledge index / validate-index (push) Has been cancelled
Validate AL review fixtures / validate-review-fixtures (push) Has been cancelled
Validate frontmatter and structure / validate (push) Has been cancelled
Improve partner onboarding and documentation navigation (#174)
Lead with a complete plugin quick start and add task-oriented usage, troubleshooting, customization, and contribution guides. Preserve the broader plugin framing, correct conflicting contract guidance, support Agents folder reviews, and align repository validation. Convert existing sample references to clickable links without changing knowledge rules.

Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-09 17:31:03 +02:00

1.7 KiB

bc-version domain keywords technologies countries application-area
18..
interfaces
unknownvalueimplementation
unknown-enum-value
persisted-ordinal
enum-extension
extension-uninstall
interface-fallback
al
w1
all

Handle unknown enum ordinals with UnknownValueImplementation

Description

An enum ordinal can remain in persisted data after the enum extension that declared it is uninstalled. The ordinal is then unknown: it matches no currently declared enum value. DefaultImplementation does not cover this case; it covers declared values that have no explicit interface implementation. UnknownValueImplementation, available from runtime 7.0 (Business Central 2021 release wave 1, BC18), provides the distinct interface implementation for an unknown ordinal.

Best Practice

On BC18 or later, set UnknownValueImplementation = <Interface> = <Codeunit>; on an enum that implements an interface and can be persisted. Use an implementation that reports a clear domain error or safely contains the unknown state. Keep DefaultImplementation separately when declared but unmapped values also need a fallback.

See sample: handle-unknown-enum-ordinals-with-unknownvalueimplementation.good.al.

Anti Pattern

Defining only DefaultImplementation and assuming it also handles a stored ordinal whose enum value has disappeared. After an enum extension is uninstalled, converting that unknown ordinal to the interface can produce a technical runtime error instead of controlled handling.

See sample: handle-unknown-enum-ordinals-with-unknownvalueimplementation.bad.al.