Search code examples
c#axaptaax

Error executing code: Wrong argument type for function


I have some code in c# which uses the AX Business connector, and its like this:

AxaptaRecord OrderRecord = (AxaptaRecord)ax.CallStaticClassMethod("BTNOnlineOrder", "getSalesOrder", salesRef);

if (OrderRecord.Found)
{
     AxaptaObject Lines = (AxaptaObject)OrderRecord.Call("querySalesLine");
     AxaptaObject qrLines = (AxaptaObject)ax.CreateAxaptaObject("QueryRun", Lines);

     while ((bool)qrLines.Call("next"))
     {
          int tableid = (int)ax.CallStaticClassMethod("Global", "tableName2Id", "InventTable");
          AxaptaRecord r = (AxaptaRecord)qrLines.Call("get", tableid);
     }  
}

I get the following error when I try to call the "get" method:

Error executing code: Wrong argument type for function.

tableid returns an int value, 175, so it's not due to tableid being null or something.

Any help would be appreciated


Solution

  • I got this to work by using the getNo method and passing 1 as the parameter. I'm not sure if it's the correct way or not but it worked for me:

    http://msdn.microsoft.com/en-us/library/aa612609(v=ax.50).aspx