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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Modify range in AOT query

(0) ShareShare
ReportReport
Posted on by 6,609

Hello and happy Friday.

I have an AOT query I'm calling from within X++ code. On the AOT query, one of the datasource I have a range defined for a specific created date values (I'm currently using greaterThanDate(-90) in the AOT query for testing). At runtime, is it possible to modify the created date range value, say to greaterThanDate(-1), from within X++ before executing the query itself? Hope that was somewhat clear.

Thank you!

*This post is locked for comments

I have the same question (0)
  • Brandt Fundak Profile Picture
    2,007 on at

    I would take a look at the SysQueryRangeUtil class:

    msdn.microsoft.com/.../sysqueryrangeutil.aspx

    Specifically the dayRange method.

    Hope that helps.

    Brandt

  • bankk Profile Picture
    6,609 on at

    Brandt, thanks for the reply but I'm not sure the question was answered. My dilemma is I have an AOT query, not one that I built in code. The AOT query contains a value in the range node which I would like to change at runtime.

    Better yet, I could phrase the question a little differently. Is it possible to add a range to an AOT query called within X++ code? So this is all I have to access the AOT query from within X++...

       Query q;

       q = new Query(queryStr([AOT query name]));

    Once I have "q", can I modify the query details?

    Thanks!

  • Suggested answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Not a problem. Find the range by QueryBuildDataSource.findRange() and change its value (QueryBuildRange.value()).

  • Verified answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Regarding the new question - yes, you can do whatever you want with such a query.

    For example, find an existing data source (e.g. q.dataSource(tableNumTable(YourTable))), add a range (addRange(fieldNum(YourTable), YourField))) and so on. You'll find many examples both in AX and on internet.

  • Community Member Profile Picture
    on at

    Hello,

    Along the lines of the same question, but totally different :-)
    Can I modified a query who already joins 2 tables and add a 3rd datasource but as a union all?

    Thanks.

  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Everything what you can do with the Query framework can be done even if you create the instance of your Query object from an AOT query.

  • Community Member Profile Picture
    on at

    Well, I'm trying to incorporate the union part programmatically to a query in which I have 2 tables already joint.

    but it doesn't seem to work. When I run SQL profiler the query doesnt take into consideration the union piece.

    Do you have any examples for union with complex queries laying around somewhere?. :-)

    Thanks.

  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    if your question isn't related to the topic of this thread ("Modify range in AOT query"), please create a new one.

  • Majid Hafeez Profile Picture
    40 on at

    Try This IT works fine:

    qbrDate = SysQuery::findOrCreateRange(query.datasourceTable(tableNum(WHSWorkTable)),fieldNum(WHSWorkTable,WorkClosedUTCDateTime));
    qbrDate.value(SysQuery::range(fromDate, todate));

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans