Business Requirement: use of not like functionality in X++
The like condition allows you to use wildcards in where clauses of an SQL statement. The not like condition as supported in SQL is not supported in X++.
Solution: use the exclamation mark
Suppose you want to find all customers in the CustTable whose Name doesn’t start with Light. As the not like condition is not supported in X++, you need to achieve this by using the exclamation mark. The exclamation mark is used throughout Dynamics AX to filter records not equal some value. In our example this would become:
static void UseOfNotLike(Args _args)
{
CustTable custTable;
;
while select custTable
where !(custTable.Name like "Light*")
{
info(strFmt("Customer account: %1, Name: %2"
,custTable.AccountNum
,custTable.Name));
}
}
Post a Comment