3

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.

DAXaholic
  • 33,312
  • 6
  • 76
  • 74
Jayaraj.K
  • 928
  • 9
  • 30

2 Answers2

4

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.

DAXaholic
  • 33,312
  • 6
  • 76
  • 74
0

replace :

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

with this :

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

Hope this help...

Setiaji
  • 106
  • 6
  • strfmt statements will automatically convert data types into strings. There is no need to apply type conversions from within the strfmt statement. – kingofzeal Dec 09 '13 at 13:52
  • Sometimes, i need it for sure while i know its useless. Thanks, kingofzeal, for reminds me again this function :) – Setiaji Dec 10 '13 at 04:41