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

Get the filter value from query

(0) ShareShare
ReportReport
Posted on by 183

Hi all,

I need to get Physical date from a query in a form to calculate the date difference. Basictly I want to get the 01-11-2020 (or full text >01-11-2020) value. How can I do it to show the value in a display method? Thanks!

stockneedsanalysis_5F00_filters.jpg

I have the same question (0)
  • Suggested answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    use queryFilter

    community.dynamics.com/.../170494

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

    It may be simple - you just need to find the range and call its value() method. For example:

    str value;
    
    QueryBuildRange range = qbds.findRange(fieldNum(InventTrans, DatePhysical));
    if (range)
    {
        value = range.value();
    }

    It becames more complicated if there can be more ranges for the same field. Also, query values may contain more things than just a single value, e.g. date ranges or methods like (day()).

  • Rafael Araujo Profile Picture
    183 on at

    Great Martin!

    It worked! Thanks!

  • Rafael Araujo Profile Picture
    183 on at

    Hi Martin,

    I know that the question was answer, but is it possible to find by range name? In this case I added two DatePhysical field, but one is the start date and the other is end date.

    pastedimage1618486129137v1.png

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

    I don't remember ever seeing any code working with a range name, nevertheless you surely could iterate ranges for a field and check their name(). Nevertheless you would have to hard-code the range name in your code, which isn't a good practice.

    Also, why do you need two ranges? Can't you simply use a single range with an inteval (e.g. "DatePhysical is between start date and end date")?

    Note that the whole idea of getting a value from range, converting it back to a date and working with it looks suspicious to me. As I mentioned before, it's not even always possible (because the value may be a list, an interval, a method or another expression).

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 565 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans