Hi,
can i use OR with Not Like in a query range?
OR with like works...
(AccountNum LIKE "005*") || (Name LIKE "SGBD*")
...but how change to Not Like
Regards
Michael
*This post is locked for comments
Hi Michael,
You can write a code like below,
For X++:
Eg. select firstOnly custTable
where !(custTable.AccountNum LIKE "*005*");
For Query:
queryBuildRange.value(!*005*);
Thanks.
Boolean operators do work with AX as mentioned above within the select statement.
http://daxdude.blogspot.hu/2011/02/use-x-wildcard-like-and-not-like-in-x.html
It also works with advanced filtering as expressions, see the bottom of this article:
http://www.axaptapedia.com/Expressions_in_query_ranges
For the query range you should consider using SysQuery:valueLike() and SysQuery::valueNot()
msdn.microsoft.com/.../sysquery.valuenot.aspx
I need OR + NOT Like in query range, not in select statement. (AX 2009)
Following is an OR + LIKE example in CustTable Form Query:
I try many, but don't find the syntax to replace LIKE with NOT LIKE.
Someone have an idea, how to do.
Or is it not possible?
Hi Michael Niemeyer,
Try this:
((AccountNum LIKE "005*") || (!(Name LIKE "SGBD*")))
Hi Ievgen,
i try it, and got following error.
Same as all my trys before
I believe the answers above is not for query dialog in advance filter. Please try to use the expresion in x++ by select statement or QueryBuildRange.
You can look into this link for example:
www.doens.be/.../using-not-like-in-ax-x
How is the syntax for OR + NOT LIKE in x++ QueryBuildRange.
It's no difference, if i use the syntax in advance filter, or in x++ QueryBuildRange.
Please look into the link that i provided. It provides the example of code.
Sorrry but i don't found an example for QueryBuildRange with OR + NOT LIKE
I found many examples before, but nothing with OR + NOT LIKE:
If you have an example syntax, please publish it here.
Ievgen's syntax is correct. I do not have AX 2009 in front of me, but are you sure you have CustTable.Name field? In AX 2012 it is no longer there.
The below code works perfectly fine in AX 2012 as per your requirements. It correctly returns all my customers that start with that specific C-account, and also return all customers which do not start with the C character.
If it does not work for you like this, then it might be a limitation of AX 2009. But first of all I would double-check that Name field.
static void WIK_LikeNotLike(Args _args) { CustTable custTable; Query query = new Query(); QueryRun queryRun; QueryBuildDataSource qbds = query.addDataSource(custTable.TableId); QueryBuildRange qbr = SysQuery::findOrCreateRange(qbds, fieldNum(CustTable, AccountNum)); str range = strFmt('((AccountNum LIKE "%1") || (!(AccountNum LIKE "%2")))', SysQuery::valueLikeAfter('C904029'), SysQuery::valueLikeAfter('C')); qbr.value(range); info(range); info(qbds.toString()); queryRun = new QueryRun(query); while (queryRun.next()) { custTable = queryRun.get(tableNum(CustTable)); info(custTable.AccountNum); } }
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Community Member 4
Martin Tocauer 4
Nayyar Siddiqi 2