web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

QueryBuildDatasource add range not equal to enum value

(0) ShareShare
ReportReport
Posted on by 916

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

I have the same question (0)
  • b_radlyjames Profile Picture
    3,157 on at

    the 'addRange' method is the way to do this.  Make sure you use enum2str on your 2 addRange lines.

  • Verified answer
    Anton Venter Profile Picture
    20,678 Super User 2026 Season 1 on at

    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

  • Verified answer
    Community Member Profile Picture
    on at

    This also works:

    this.query().dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable, InvoiceAccount)).value('!Transfer'+','+'!5050');

  • Verified answer
    Community Member Profile Picture
    on at

    This works with multiple ENUMS:

    this.query().dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable, PurchStatus)).value(strfmt('!%1,!%2',enum2str(PurchStatus::Canceled),enum2str(purchstatus::Invoiced)));

  • Dang Vo Profile Picture
    31 on at

    that good for me

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.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
imran ul haq Profile Picture

imran ul haq 8

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 4 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans