Skip to main content

Posts

Showing posts with the label not like

"Like" with "AND" Operator through Query in Dynamics Ax

static void RAJ_AndLikeOperator(Args _args) Query query = new Query(); QueryRun queryRun; InventTable inventTable; ; query.addDataSource(tableNum(InventTable)).addRange(fieldNum(InventTable, ItemId)).value("100*, 110*, 120*"); queryRun = new QueryRun(query); while(queryRun.next()) inventTable = queryRun.get(tableNum(InventTable)); info(inventTable.ItemId); } }

Not Like’ in Dynamics AX

In X++, we can use Like ‘*someIdentifier’ to implement the Like keyword. e.g. select firstonly purchTable where purchTable.purchId like ‘ 00007* ‘; However if you want to use ‘Not Like’ in X++ SQL statement, you have three options: The first option, using ‘!’ as ‘not’, e.g. select firstonly purchTable where !(purchTable.purchId like ‘ 00007* ‘); The second option, using notExists join e.g. PurchTable purchTable, refPurchTable; ; select firstonly purchTable notExists join refPurchTable where purchTable.purchId == ‘ 00007* ‘; Please make sure that you do put purchTable.purchId in condition statement, otherwise the SQL statement will retrieve an empty result set. The last option, using Query e.g. Query query = new Query(); QueryRun queryRun; ; query.addDataSource(tableNum(PurchTable)).addRange(fieldNum(PurchTable, PurchId)).value(‘ !00007* ‘); queryRun = new QueryRun(query); if(queryRun.next()) { purchTable = queryRun.get( tableNum (PurchTable))...