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 :
Finance | Project Operations, Human Resources, ...
Answered

AOT Query range on one column with OR condition of another column.

(0) ShareShare
ReportReport
Posted on by 489

Hi All,
Is there any possibilities to add AOT query range with OR condition with 2 different fields on one field ?

Like Below: 

( salesTable.DocumentStatus = None || (salesTable.DocumentStatus != None && salesTable.TestConfirmationStatus = ToBeConfirmed ))

Description: I am developing a workspace form and there i want to show the count of sales order with above conditions. 
pastedimage1671779387151v1.png
pastedimage1671779505165v2.png

I have the same question (0)
  • GirishS Profile Picture
    27,843 Moderator on at

    Hi Vijay Yelmame,

    I don't think you can add range with multiple fields in one range.

    It will be better if you can add above range in the workspace form through code.

    Thanks,

    Girish S.

  • Verified answer
    Martin Dráb Profile Picture
    239,636 Most Valuable Professional on at

    You should be able to use something like this:

    ((DocumentStatus = DocumentStatus::None) || (TestConfirmationStatus = YourEnum::ToBeConfirmed))

    You can find quite a few examples in existing queries, such as PurchRFQAllReplySummary_PSN:

    4370.query.jpg

  • Vijay Yelmame VY Profile Picture
    489 on at

    Thank Martin for your help. I am now able to filter on the query. by adding range like below.

    (DOCUMENTSTATUS == 0),(DOCUMENTSTATUS != 0 && TESTCONFIRMATIONSTATUS == 1)
    pastedimage1671807447580v1.png

    I am trying to add similar range from X query on form DataSource but not sure why it is not working. Even in the info as well i am getting below query but my form DataSource is not filtering the record according to this query.

    SELECT FIRSTFAST FORUPDATE * FROM NCABAllSOLinesView(TESTAllSOLinesView) WHERE (((TESTAllSOLinesView.DocumentStatus == "0") || ((TESTAllSOLinesView.NCABConfirmationStatus == "1") && (TESTAllSOLinesView.DocumentStatus != "0"))))

    Below code is in the data source execute query.

    this.query().dataSourceTable(tableNum(TESTAllSOLinesView)).addRange(fieldNum(TESTAllSOLinesView,DocumentStatus)).value(
        strFmt('(%1.%2 == "0") || ((%1.%3 == "1") && (%1.%2 != "0"))',tableStr(TESTAllSOLinesView),fieldStr(TESTAllSOLinesView, DocumentStatus),fieldStr(TESTAllSOLinesView, TESTConfirmationStatus)));
        
        Query q2 = new Query(this.query());
    
        info(strfmt("%1",q2));

  • Martin Dráb Profile Picture
    239,636 Most Valuable Professional on at

    You're missing out-most parentheses.

    Another problem is that data source may have different names than tables. Use name() method of QueryBuildDataSource instead of tableStr().

    Hard-coding enum elements numbers is a bad idea, and it may give you completely wrong result if any of the enums if extensible. Use enums instead, such as DocumentStatus::None instead of 0.

    Correct me if I'm wrong, but I don't think you need the check for DocumentStatus != DocumentStatus::None.

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 797

#2
André Arnaud de Calavon Profile Picture

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

#3
Subra Profile Picture

Subra 534

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans