Interfaces
Interfaces in AL: how to declare them, implement them in codeunits, give methods default implementations, extend interfaces, and manage method changes over time. It answers questions about polymorphism, the is and as operators, and safely adding or removing interface methods in published extensions.
- 4Learn pages
- 2videos
Path: Development > Programming in the AL language > Language elements > Interfaces · tier official · system development · narrative reviewed (checked by Opus)
Overview
Interfaces in AL define syntactical contracts that codeunits implement, which supports polymorphic programming. The section has four pages and no subtopics. They cover the basics, extension of interfaces, type testing and casting, and the lifecycle of interface methods.
Key points
- Start with ‘Interfaces in AL’: interface declaration, the implements keyword, and Go to Implementations.
- Interfaces can have default method implementations, and a default method can later transition to a required method.
- ‘Extend interfaces in AL’ lets an interface extend other interfaces and inherit their methods (2024 release wave 2).
- The is operator tests whether an interface supports a given interface or method, and the as operator casts it (2024 release wave 2).
- Type testing and casting are mainly useful when extending interfaces.
- Interface method lifecycle in published extensions uses Default, RequiredPending, and Obsolete states to keep backward compatibility.
- The lifecycle page also covers required methods, a runtime identifier, and AppSourceCop rules.
- The ‘Interfaces in AL’ page mentions 2023 release wave 1 and 2026 release wave 2 as version points.
Learn pages
- Extend interfaces in AL: Learn how to extend interfaces in AL to create flexible and adaptable extensions.
- Interface method lifecycle: Learn the recommended lifecycle for adding, transitioning, and removing interface methods in AL.
- Interfaces in AL: Learn about interfaces in AL, including default method implementations and the RequiredPending attribute for evolving interfaces safely.
- Type testing and casting operators for interfaces in AL: Learn how to use the
isandasoperators for type testing and casting interfaces in AL for Business Central.
Videos, posts and code changes
Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.
- #98 Add P0 event and interface compatibility knowledge (code change): “Guidelines for extending published interfaces with versioned siblings and BC25+ extends syntax”
- Evolve AL Interfaces with Default Implementations in Business Central 29.0 (community post): “Interfaces can now provide default method bodies”
- Business Central 29 0 Default Implementations in AL Interfaces (video): “Default implementation for AL interfaces; Required pending attribute”
- What’s New: AL - Interfaces (2024 release wave 2) (video): “Interface Extension; Type Checking with Is Operator for Interfaces; Interface Casting with As Operator”
Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.