web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Active Discussion

System.ArgumentException error when using VARIANT datatype as part of a AL Report Dataset Column

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Up to version 14.x (included) it was possible with C/AL and AL to add a VARIANT datatype to a column in the dataset.

Since version 15.x onwards, Microsoft implemented the capability of serializing the dataset as part of the cloud printing enablement slice. This involved dataset being in need to have a specific datatype assigned. Adding a VARIANT to a dataset column would result, then, in a runtime error like the one shown below

…

Type: System.ArgumentException

Message:

  Type 'System.Object' is not known to the NavSerializer.

  Parameter name: typeHandle

ParamName: typeHandle

StackTrace:

     at Microsoft.Dynamics.Nav.Types.Data.NavSerializer.GetTypeCode(RuntimeTypeHandle typeHandle)

     at Microsoft.Dynamics.Nav.Types.Data.NavDataColumn.set_DataType(Type value)

     at Microsoft.Dynamics.Nav.Types.NavDataSetBuilder.AddColumnToDataTable(MetaDataItemColumn field, NavDataTable dataTable)

     at Microsoft.Dynamics.Nav.Types.NavDataSetBuilder.CreateNavDataSet(MetaReport metaReport)

…

Adding a VARIANT datatype to a column will throw an error at design time when building the package (CTRL+SHIFT+B) starting from 18.x (Dynamics 365 Business Central 2021 Wave 1).

Considering all previous versions, using AL Language Extension Build 6.1.362735 or higher

A Warning will be thrown at design time when compiling like the following

…

Microsoft (R) AL Compiler version 6.1.5.35065

Copyright (C) Microsoft Corporation. All rights reserved

Compilation started for project 'ReportVariant' containing '1' files at '12:53:15.538'. 

c:\APP\ReportVariant\src\report\Rep50100.ReportVariant.al(13,41): warning AL0638: 'Variant' is not a valid column type for column 'VariantVar' in report 'ReportVariant'. This warning will become an error when targeting a runtime with version '7.0' or higher.

 Compilation ended at '12:53:18.452'.

Success: The package is created.

...

Deploying such app will result in a System.ArgumentException error.

If you have some development that is using VARIANT datatype within a report column you might think of applying some of these workarounds:

  1. Always pass a TEXT code
  2. Use VB.NET code within your report to evaluate if this is a Text or Decimal value or whatever (create your own function or use CDec or IsDecimal, e.g. if you have decimal ) 

Another solution might be

  1. Add 2 different column in the dataset for Text and Decimal (or whatever)
  2. Add 2 – or N - textboxes with the same dimension in the same position one on top of the other and conditionally display one or the other
  3. Alternative to b., if this is part of Tablix lines, you might add N extra lines with conditional visibility set, depending on if this has been set to decimal or text or whatever other datatype.
  • Marco Mels Profile Picture
    Microsoft Employee on at

    Thank you for sharing Duilio!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 624 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 440 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 244 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans