Announcements
I'm in AX 2012 R3 environment.I would like to add a query range to GeneralJournalEntry table and filter out rows that have a JournalCategory value different to LedgerTransType::Purch , i try this but not works :
datasource.addRange(fieldnum(GeneralJournalEntry,JournalCategory)).value(SysQuery::valueNot(enum2str(LedgerTransType::Purch)));
Update : it works for one range ,but what if i want add multiple value to range like this :
datasource.addRange(fieldnum(GeneralJournalEntry,JournalCategory)).value(SysQuery::valueNot(LedgerTransType::Sales)); datasource.addRange(fieldnum(GeneralJournalEntry,JournalCategory)).value(SysQuery::valueNot(LedgerTransType::Purch));
In sql we have :
select * from GENERALJOURNALENTRY where GENERALJOURNALENTRY.JOURNALCATEGORY not in (2,3)
*This post is locked for comments
that good for me
This works with multiple ENUMS:
this.query().dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable, PurchStatus)).value(strfmt('!%1,!%2',enum2str(PurchStatus::Canceled),enum2str(purchstatus::Invoiced)));
This also works:
this.query().dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable, InvoiceAccount)).value('!Transfer'+','+'!5050');
Standard query ranges result in an "OR" operator in the SQL and when you are doing a "NOT", you should have "AND" instead. To achieve this in AX using query ranges, use expressions in query ranges, see http://www.axaptapedia.com/Expressions_in_query_ranges
the 'addRange' method is the way to do this. Make sure you use enum2str on your 2 addRange lines.
André Arnaud de Cal...
294,095
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator