Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to create AX Query Range like SQL where

Posted on by 305

Hello,

I need to create a AX query for user convenient to use.

so I need a AX query like SQL:

select PRODID , ItemId , REMAINBOMFINANCIAL ,QTYBOMCALC
from PRODBOM as PB
where REMAINBOMFINANCIAL > QTYBOMCALC

I try and no way in AX query Range like SQL where REMAINBOMFINANCIAL > QTYBOMCALC

someone Table.Field1 > Table.Fiel2

Please help and thanks in advance.

BR, Jen

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: How to create AX Query Range like SQL where

    Dipen, we're just discussing an identical requirement in How to add range on multiple field with same value.

  • RE: How to create AX Query Range like SQL where

    hello 

    i create one form and give ranges in execute query method .

    the issue is in my table 2 fields approver 1 and approver 2.

    so I have to check that if which user runs a form that user name is either in approver 1 or approver 2 then that line is shown in form otherwise not

    so my question is how can I give ranges 2 different fields of one table with same value using OR condition please suggest any idea

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to create AX Query Range like SQL where
    Query query = new Query();
    QueryBuildDataSource qbds = query.addDataSource(tableNum(ProdBOM));
        
        
    qbds.addRange(fieldNum(ProdBOM, RemainBomFinancial)).value(strFmt('(%1.%2 > %1.%3)', 
                                                                qbds.name(), 
                                                                fieldStr(ProdBOM, RemainBomFinancial), 
                                                                fieldStr(ProdBOM, QtyBomCalc)));
        
    info(query.toString());

    This prints to infolog:

    Query  object 10aa8230: SELECT * FROM ProdBOM(ProdBOM_1) WHERE (((ProdBOM_1.RemainBomFinancial > ProdBOM_1.QtyBomCalc)))
    
  • ATMA-Jen Profile Picture
    ATMA-Jen 305 on at
    RE: How to create AX Query Range like SQL where

    Hello Nikolaos,

    My purpose is very simply.

    I need put the SQL Data in AX for user just one click to use.

    SQL:

    select PRODID , ItemId , REMAINBOMFINANCIAL ,QTYBOMCALC

    from PRODBOM as PB

    where REMAINBOMFINANCIAL > QTYBOMCALC

    Please tell me how to do? step by step.

    I am really junior in AX.

    Thanks in advance.

    BR, Jen

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to create AX Query Range like SQL where

    The Microsoft article that I shared contains examples on how to add "complex" ranges in queries in x++.

    If you still have difficulties, please give more details about your use case and our existing code. It helps us to help you.

  • ATMA-Jen Profile Picture
    ATMA-Jen 305 on at
    RE: How to create AX Query Range like SQL where

    Hello Nikolaos,

    I still don't know how to do ?

    Have any case study to learning about this case?

    thanks.

    BR, Jen

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to create AX Query Range like SQL where

    1. No, it's not possible. You can use expressions in query ranges only in x++

    2. With SSRS reports you can apply the range with x++ in the data provider class, or use an x++ select statement to populate a temp table and use that temp table as the data source for your report.

  • ATMA-Jen Profile Picture
    ATMA-Jen 305 on at
    RE: How to create AX Query Range like SQL where

    Hello,

    Please tell me how to setup the AX AOT Query Range's Value field to filter the data that RemainBOMFinancial >QtyBOMCalc

    thanks in advance.

    AX190105_2D00_01.jpg

  • ATMA-Jen Profile Picture
    ATMA-Jen 305 on at
    RE: How to create AX Query Range like SQL where

    Hello  Nikolaos,

    I saw this article, but I still can't get the way (expression how to write).

    I have 2 question:

    1. I can use AX AOT Query the Value Field to expression??

    or Just can use X++ to build the Query in a Job

    2. I make AX Query Form or SSRS report , how to join the Job-Query??

    please help & thanks in advance.

    Br, Jen

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to create AX Query Range like SQL where

    This article explains how to use expressions in query ranges: docs.microsoft.com/.../using-expressions-in-query-ranges

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans