Dynamics 365 Business Central: returning complex types from AL

I think that every AL developer dreams that a day AL will be a full Object Oriented programming language like C# or others. Unfortunately, AL is born from C/AL and its main purpose is to write business logic inside a business application like an ERP in the cloud, it’s not a language that will be used for writing every type of apps. But that is… don’t stop to suggest things, don’t stop to propose ideas, something is cooking… 🙂

How many times for example you had the need to write a procedure that return complex types like a Customer record? You cannot do that now, but…

From Business Central 2021 Wave 1 most types can be returned from procedures – both user-defined types and most built-in types

This means that you can now write something like:

and you can also use the complex return type directly as part of other expressions, like:

You can also return List and Dictionary objects:

Unfortunately, you cannot actually return a List of complex types like in the following example:

This was asked a lot, but there are 2 months until April… 😉

You can also return complex built-in types like for example:

As you can see, here I’m calling a web service (with a GET request) and the procedure directly returns a HttpResponseMessage object.

You can also return other complex types like:

Cool isn’t it? Small things for a C# developer, but a huge improvements for AL… 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.