Search code examples
axaptax++dynamics-ax-2012-r3

Fill the nullable .net service method in AX2012


I want to set argument in a .net service methot. This method parameter type Nullable'1.

I create a method which name is findLastDate, return type of this method is TransDate. But when run the process take an error ;

System.NotSupportedException: DateTimeConverter cannot convert from Microsoft.Dynamics.Ax.Xpp.AxShared.utcdatetime.

Then i change findLastDate method's returntype to utcDateTime but unfortunately.

How can i fill this service method?

enter image description here


Solution

  • It looks like your issue isn't related to null but due to marshaling AX and CLR types.

    See - https://learn.microsoft.com/en-us/dynamicsax-2012/developer/how-to-marshal-between-x-and-clr-primitive-types#code-sample-for-systemdatetime for how to marshal between the two.

    I linked to the System.DateTime example in the article.