Operand types are not compatible with the operator in AX2009

3.4k Views Asked by At

I am a beginner in AX .I have tried to to execute a code in AOT job.I got an error like this Operand types are not compatible with the operator. and the code which I have tried to work out is as follows.

static void SelectQueryTest(Args _args)
{
   int64  countItem;
   countItem = (select count(ItemId) from InventTable where InventTable.ItemGroupId== "100").ItemId;
   info(strFmt("Count: %1", countItem));
}

Can anyone help me where I have gone wrong.

2

There are 2 best solutions below

0
On BEST ANSWER

The field ItemId is a String so you can not assign it to an int64. Replace count(ItemId) with count(RecId) and use this field as your result. Counting records into field RecId is also good practice as it shows your intention very clearly to someone familiar with AX.

2
On

replace :

info(strFmt("Count: %1", countItem));

with this :

info(strfmt("Count: %1", int2str(countItem)));

Hope this help...