Skip to content

#021 Returning Complex Types in AL

One of the big limitations we had in C/AL was the impossibility to return complex types in functions. We could only use simple data types as Code, Text, Boolean, Integer, etc. Every time we needed to return, for example a record, we used the Var parameter.

We are happy to announce that starting on Business Central 2021 release wave 1, Microsoft added the possibility to return user defined types like for example records, pages and codeunits. Also new data types as HttpClient or HttpResponseMessage is possible to use.

Examples of code you can write:

1 Return a record

Return a record_image#020

2 Use the return as part of expressions

Use in complex built-in types_image#020

3 Use in complex built-in types

Use the return as part of expressions_image#020

Official documentation from Microsoft is available here https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-al-complextypes.