In modern AL, we have fancy constructs like Lists and Dictionaries, but none of those can hold all datatypes in AL. For this, you’ll have to turn to a classic, you’ll have to use arrays. Check out the video:

In this video, Erik reminds us that while newer AL data types like List and Dictionary get all the attention, the humble array has a superpower they don’t: it can hold any data type — including Records, Codeunits, RecordRefs, and more. If you’ve been overlooking arrays in Business Central AL development, it’s time for a refresher.
Lists and Dictionaries Are Great, But Limited
When List and Dictionary types were introduced in AL, they quickly became popular — and for good reason. They’re dynamic, flexible, and easy to work with. However, they come with an important limitation: they can only hold primitive values like strings, integers, and other simple types. You can even have a list of lists, but you cannot have a list of Records, a list of Codeunits, or a list of RecordRefs.
But you know what can hold all of those things? An array.
Array Basics: A Quick Refresher
Declaring an array in AL is straightforward. You specify the size and the type:
var
R: Array[10] of Text;
You can then assign and read values using a one-based index:
R[3] := 'Hello';
R[6] := 'Hello 2';
for I := 1 to 10 do
Message(R[I]);
Running this will display blank messages for unassigned slots, then “Hello” for index 3 and “Hello 2” for index 6. The index doesn’t need to be a constant — you can loop through arrays dynamically.
Multi-Dimensional Arrays
AL supports multi-dimensional arrays — up to 10 dimensions. You could declare something like:
var
R: Array[10, 10, 10] of Text; // 3-dimensional
You can go all the way up to 10 dimensions, but there’s a hard limit: the maximum total number of elements is 1,000,000. So while you can get creative with dimensions, the total element count caps out.
The Trade-Off: Fixed Size
The reason many developers dismiss arrays is that they have a fixed length. You cannot declare an array with a variable size:
// This does NOT compile:
procedure Test(I: Integer)
var
R: Array[I] of Text; // Error!
begin
end;
The dimension must be a constant known at compile time. For some applications, this is a deal-breaker. But for many real-world scenarios, it absolutely isn’t. You simply pick a reasonable maximum — 100, 200, whatever makes sense — and manage which slots are in use.
The Real Power: Arrays of Anything
Here’s where it gets interesting. When you start typing Array[10] of in AL and look at IntelliSense, the list of available types goes on and on. You can create arrays of virtually every data type in AL:
- Arrays of Records:
Array[5] of Record "Sales Header" - Arrays of Codeunits:
Array[5] of Codeunit "Sales-Post" - Arrays of RecordRefs:
Array[100] of RecordRef - And many more — essentially anything you can declare as a variable
This is something Lists and Dictionaries simply cannot do.
A Real-World Example: The Toolbox App
Erik shares a practical example from his own Toolbox app, where he needs to hold a dynamic set of RecordRef variables at runtime. The solution is elegantly simple:
pageextension 50100 CustomerListExt extends "Customer List"
{
trigger OnOpenPage();
var
Refs: Array[100] of RecordRef;
begin
end;
}
The array holds up to 100 RecordRef variables, with some logic to track which slots are occupied and which are free. The alternative — declaring R1, R2, R3, and so on as individual variables — would be absurd. The array keeps the code clean and readable.
In practice, the average Toolbox script uses just one or two record variables. Even extreme cases might need 25. Setting the maximum to 100 provides plenty of headroom. And if someone ever files a support ticket saying they need 101? Just bump it up.
Conclusion
Don’t discount arrays in AL. While List and Dictionary are excellent for primitive types, arrays remain the only way to hold collections of complex types like Records, Codeunits, RecordRefs, and more. Yes, they have a fixed size — but that’s often a perfectly acceptable trade-off. Arrays have been around forever, they work reliably, and they enable patterns that no other AL data structure can. Go try it out!