AL Interfaces and Other Dynamics 365 Business Central Wave 1 Features

With 2020 spring comes not only Coronavirus but also the new Business Central version and Wave 1 features that introduce a new programming capability interface. In this article, we are going to review some of the Dynamics 365 Business Central Wave 1 features that caught our technical team’s eye.

 

1. Dynamics 365 Business Central Wave 1 features: AL interfaces

 

Probably most of you heard about the term Interface. Some of you that previously used only procedural programming languages might think that interface is the user interface, but today we are going to talk about interfaces used in object orientated languages, such as C# or Java. To make it more complicated, let’s take interface meaning from C# documentation: 

An interface defines a contract. Any class or struct that implements a contract must provide an implementation of the members defined in the interface. 

Probably not the most informative definition, but technically, it’s the same for AL too. In AL, such as in other languages, the interface is a new object type in which you could define that procedures should exist in objects that implement that interface. Here’s an example:

 

So this is an interface with the declared procedure, it has the only declaration, but the body is missing. We need to declare the body in codeunit that implements this interface, like in the next picture.

 

Ok, now you might think, why we need this fancy way of declaring method? Let‘s create the second codeunit, that implements the same interface, just change the message to „Bye“.

 

And also modify HelloWorld template to call these codeunits:

 

As you can see, in the procedure SayHiBye body, we only declared our TestInterface. As our codeunits implement this Interface, we could pass them to function as a parameter, and call one or another procedure. So, if we run this code, the output looks like this:

 

And

 

Codeunits could implement more than one interface. The only concern that I found, but it‘s probably due to my ignorance, is how to automatically declare Interface procedures definitions in codeunits, that implements the interface, if somebody knows how to do it, please write the answer in comments.

2. Dynamics 365 Business Central Wave 1 features: look up events and insert event subscriber in code

 

Another Wave 1 feature that I quite like, is looking up for an event, then inserting the new subscribes. Just press shift + alt +e and a new menu with event choices will appear:

 

Select one of them, and BAM, you have complete event subscriber with all of its parameters.

 

This Wave 1 feature also works with all dependant solutions, so if you have more than one dependant extension or your Base App is modified and has new events, this feature comes handy.

3. Dynamics 365 Business Central Wave 1 features: obsolete tag

 

Now you can freely add an obsolete tag and specify features that are not going to see the future. Its usage is quite simple:

 

In this example, I place an obsolete tag on the OnAfterHi event, and now it comes with a warning.

Objects that support ObsoleteState and Obsoleteattribute properties, now also get new ObsoleteTag property, to provide additional information.

 

4. Dynamics 365 Business Central Wave 1 features: ability to see database lock and table sizes

 

There is also a couple of new pages that could help with data migration and development. One of them is Database Lock. On this page, you can see all database locks and which session causes them. The second page is table sizes, in which you can see how much data is in different tables around the solution.

All in all, it’s always nice to see some new features that make the whole process way easier and save you tons of time. This time, Dynamics 365 Business Central Wave 1 features improving developers’ experience in an unexpectable way and makes me wonder what the upcoming release is going to bring.

Found this article interesting? If you want to deepen your knowledge in Dynamics 365 Business Central and gain new expertise, please check out our Dynamics 365 Business Central Extensions Training. We provide training that might be adjusted to partners’ needs and include not only theoretical but practical training as well.