Developer forum

Forum » Integration » The NAV codeunit function that is used for StockLocationId- ConvertCodeToInt returns negative values that cannot be handled by DW admin

The NAV codeunit function that is used for StockLocationId- ConvertCodeToInt returns negative values that cannot be handled by DW admin

Jon Thorne
Jon Thorne
Reply

Hi,

Another interesting one for NAV codeunit.

This function that is used for StockLocations - ConvertCodeToInt - uses a .NET function GetHashCode(). This function can sometimes return negative values. When this is imported into NAV the records are created, but the DW admin interface cannot load these records correctly. Also, I was reading that the GetHashCode function can return different values on different builds. So the number may change.

  LOCAL PROCEDURE ConvertCodeToInt@1000000036(code@1000000000 : Code[10]) : Integer;
    VAR
      i@1000000004 : Integer;
      dotNetString@1000000005 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.String";
    BEGIN
      dotNetString := code;
      i := dotNetString.GetHashCode();
      EXIT(i);
    END;

Is there any issue in just returning the absolute value of this code in case it is negative? Or any other suggestions or something I have missed?

For now, I just might need to create a table script to convert these values on import.

Regards, Jon.

 


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Jon,
thx for the information, we will look into this and fix it.
BR, Dmitrij

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Jon,
this issue is now fixed in the NAV 2018 1.2.0.18 version.
BR, Dmitrij

 

You must be logged in to post in the forum