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 172

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

  • Martin Dráb Profile Picture
    231,758 Most Valuable Professional on at
    RE: Get the filter value from query

    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).

  • Rafael Araujo Profile Picture
    172 on at
    RE: Get the filter value from query

    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

  • Rafael Araujo Profile Picture
    172 on at
    RE: Get the filter value from query

    Great Martin!

    It worked! Thanks!

  • Verified answer
    Martin Dráb Profile Picture
    231,758 Most Valuable Professional on at
    RE: Get the filter value from query

    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()).

  • Suggested answer
    ergun sahin Profile Picture
    8,816 Moderator on at
    RE: Get the filter value from query

    use queryFilter

    community.dynamics.com/.../170494

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,758 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans