Retrieving date/datetime from ADO.NET into a record field

In Dynamics AX, you can use ADO.NET to retrieve data from external data sources.  This is quite easy to do for text and numeric data types, but not for Date or DateTime data types.

If you try a simple assign, you’ll end up throwing an exception:

blocks.Field1 = reader.get_Item( "REGISTRATIONDATE" );

Error executing code: Wrong argument types in variable assignment.

Using SqlDataReader.GetDataTypeName() to check the data type, it shows DateTime2.  The destination field is a datetime field, but this problem as well as the solution happens even for plain date fields.

So, we might try to use SqlDataReader.GetDateTime() instead, but that results in exactly the same error.

Continue reading “Retrieving date/datetime from ADO.NET into a record field”

Importing data to AX from a fillable PDF form

Recently, a requirement came up for importing data from a fillable PDF form into Dynamics AX 2012.  With the right tools, this is actually quite straightforward.

PDF Labs have a product called PDFTK Server, which is a free download.  However, if you need commercial support from them that’s a paid service.  Likewise, if you want to redistribute the software and your software is not licensed under the GPL (Hint, Dynamics AX is most certainly not GPL-licensed…), you’ll need a redistribution license.  The link to the license is here, and the product download is here.

Continue reading “Importing data to AX from a fillable PDF form”

Dynamics AX CIL is not incremental, just mental…

In Dynamics AX 2012, you may some times get this error message when generating CIL code:

Cannot create a record in SysXppAssembly (SysXppAssembly). The record already exists.

I see this quite frequently when generating incremental CIL, to the point where I consider incremental CIL to be thoroughly broken.  Do yourself a favour and do full CIL generation every time, you will save time in the long run from not having to troubleshoot weird and wonderful errors…

Also, I have made it a habit to delete the files directly under the xppIl folder for the relevant AOS when this happens.

Another form trick, copy-down in grids

A function I have often been asked for, but which does not exist in standard Dynamics AX 2012 is copy-down, or the ability to press a key on the keyboard to copy values into the currently selected field from the row immediately above it.  In my implementation, I have chosen the F11 key, as it was not used for anything else.

The function will be available on all grid-based forms, even in the table browser.

Continue reading “Another form trick, copy-down in grids”

Show environment bar in Dynamics AX forms

When working with multiple Dynamics AX environments, it’s quite useful to have a visual reminder of which environment you’re working in.

It is possible to use the instance name in the client configuration to provide this hint, but the instance name is not validated, nor does it indicate to the client which instance to connect to.  The connection is established only based on the host name, port name and WSDL port.  It is, in fact, possible to specify anything at all as the instance name:

My production server does NOT have an instance named MickeyMouse.  I promise…  Really…

Continue reading “Show environment bar in Dynamics AX forms”