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

Announcements

News and Announcements icon
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 191

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
    239,784 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
    191 on at

    Great Martin!

    It worked! Thanks!

  • Rafael Araujo Profile Picture
    191 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
    239,784 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 554 Super User 2026 Season 1

#2
André Arnaud de Calavon Profile Picture

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

#3
Subra Profile Picture

Subra 422

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans