AL interfaces

Enabled for Public preview General availability
Admins, makers, or analysts, automatically This feature is released. Feb 1, 2020 This feature is released. Apr 2, 2020

Business value

An interface is used when you want to decide which capabilities need to be available for an object, while allowing actual implementations to differ, as long as they comply with the defined interface.

This allows for writing code that reduces the dependency on implementation details, makes it easier to reuse code, and supports a polymorphing way of calling object methods, which again can be used for substituting business logic.

Feature details

Use the new interface object to declare an interface name along with its methods, and apply the implements keyword along with the interface names on objects that implement the interface methods.

The interface object itself does not contain any code, only signatures, and cannot itself be called from code, but must be implemented by other objects.

The compiler checks to ensure implementations adhere to assigned interfaces.

A new QuickFix CodeAction can be used to insert interface stubs, if the compiler errors on one or more interface implementations are missing.

You can declare variables as a given interface to allow passing objects that implement the interface, and then call interface implementations on the passed object in a polymorphic manner.

Define interfaces to capture intent and create alternate implementations

See also

Interfaces in AL (docs)