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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Suggested Answer

findOrCreateRange() in date range

(0) ShareShare
ReportReport
Posted on by 30

Dear All,

I saw below code any many queries in for date range :

SysQuery::findOrCreateRange(this.queryBuildDataSource(),
fieldNum(ProdTable, FinishedDate)).value(SysQuery::range(12\01\2017, 12\31\2017);

Can you please let me know how it's work findOrCreateRange() in date range.
Please give me more shed on this.

Thanks!

Arpan

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mahmoud Hakim Profile Picture
    17,887 on at

    you will retrieve data between this dates,

    like between in SQL server

  • @rp@n Profile Picture
    30 on at

    Thanks Hakim,

    That i understand but i am concern about findOrCreateRange() only.

    How it's work findOrCreateRange() ? Please explain. 

    Please give me more shed on thsi.

    Arpan

  • Suggested answer
    Martin Dráb Profile Picture
    238,050 Most Valuable Professional on at

    The method name already says it: either finds a range or (if it can't find any) it creates a new one.

    If you want to know how exactly SysQuery::findOrCreateRange() works, simply open it in the code editor and take a look. You play with AX for some time already; you should be able to handle such basic by yourself.

  • @rp@n Profile Picture
    30 on at

    Thanks Martin

    You are correct. I am also assume the same thing.

    but i confuse in one thing so i post in blog.

    findOrCreate() :

    find :

    if find the range means already i given a range so obviously it will find the range.

    create :

    You told that it will create a new Range if not found.

    Means if i not mentioned date ranges in query then it will create a new range? 

    Please give me more shed on this.

    Arpan

  • Martin Dráb Profile Picture
    238,050 Most Valuable Professional on at

    Yes, it creates a new range if there is no existing range for the given field. What's so complicated about it?

  • @rp@n Profile Picture
    30 on at

    Thanks Martin,

    Means suppose in dialog "from Date" and "To date" i have given date ranges.

    But in qbds i not mentioned ranges for fromdate and toDate. Then it will automatically create range with Table example "LedgerTrans > Transdate?

    Please give me more shed on this.

    Arpan

  • Martin Dráb Profile Picture
    238,050 Most Valuable Professional on at

    It depends on what you're doing in your dialog, which you didn't explain.

    If you're adding ranges to a query in the SysQuery form, it will create ranges for the fields you select. If you just have custom dialog fields, it has nothing to do with any query and no range will be magically added there.

  • @rp@n Profile Picture
    30 on at

    Martin, i am trying to say it's simple dialog in report. which contain From date and To date.

    Suppose if i not put values in from date and Todate  then tell me it will crate a range for me ?

    Please give me more shed on this.

    Arpan

  • @rp@n Profile Picture
    30 on at

    Thanks Sokrut

    then how and when createrange()  will work? Please give me an example.

    I just wanted to know how createrange() will work in real scenario.

    Please give me an example.

    Arpan

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

News and Announcements

Season of Giving Solutions is Here!

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 2 Most Valuable Professional

#1
Nakul Profile Picture

Nakul 2

#3
Umar-Usman Profile Picture

Umar-Usman 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans