Search code examples
x++dynamics-ax-2012-r2

Dynamics AX 2012 parsing Int32 to table field integer


I'm using a referenced DLL to retrieve data from a webservice. The data retrieves well. I copy over some of the fields to inMemory tables. This works well unless for the Int32 types.

Code example:

As you can see, the Id field is of type Int32. The table field (ProductId) is an Integer. This compiles without errors, but when i run the code i get the following error:

Error executing code: Wrong argument types in variable assignment.

This error points to the line with the productId. Removing it makes the code work. I've also tried making the Id a string, and then str2int() the field but that doesn't work either.

Any idea's?

Thanks, steve


Solution

  • Try to marshal explicitly between the two types:

    System.Int32 netInt;
    int          xppInt;
    ;
    
    // -- Other code
    // ...
    netInt = product.get_Id();
    xppInt = netInt;
    tempData.ProductId = xppInt;