O'Reilly logo

Microsoft Dynamics NAV by Mark Brummel, Christopher Studebaker, David Studebaker, David Roys, Vjekoslav Babić, Cristina Nicolàs Lorente, Laura Nicolàs Lorente, Alex Chow

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Variant variables

Although it is not generally recommended, it might be required from time-to-time to be able to call a function with different types of records as parameters. With the strongly typed record variable parameters, this is not possible. However, we can use the Variant datatype as a workaround. We can store every variable type in NAV in a Variant.

Note

All the C/AL code that we write is converted into C# code in the background, and this C# code generates a class for each object. The Variant datatype maps to the C# type of the object. So, if we use this datatype as a parameter of a function, we can call this function with any object in NAV.

In the object, we can change the object back to a specific table using the RecordRef datatype if ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required