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)

clearing query ranges

(0) ShareShare
ReportReport
Posted on by

Hi All,

I am using AX2012 R3 CU13.

There is a typical requirement from customer for a search in a form which made me to apply query range from a set ( setS ) of values  as follows :

In method :  applyqueryfilters(_query)

pfrds = sysquery::findorcreatedatasource(_query,TableAbc);

sI = new SetIterator(setS);

while (sI.more())
{
pfrds.addRange(fieldNum(TableAbc , QId)).value(sI.value());
sI.next();
}

Now whenever there is a new search the Set changes and the results are expected to fetch accordingly.

I tried clearing the ranges by :

_query.dataSourceTable(tableNum(TableAbc)).clearRange(fieldNum(TableAbc,QId)); or

or using pfrds.clearRange(fieldNum(TableAbc,QId))

However I am unable to clear the range completely . For example if they are 4 elements on the set and I use either of the above statements the filter on only one element is cleared. To clear the entire range apparently i will have to write the clearRange statement for the number of times as the length of the set. 

Could anyone please let me know how can I clear entire range of previous set using only one statement.

PS : there are already different ranges applied on other fields in TableAbc .

Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    You could use clearRanges() to remove all ranges (for all fields) and add again what you need.

    If it's not suitable for you, you'll have to give up the requirement for "using only one statement". Of course, you can wrap the logic for removing multiple ranges to one method and use the single method call where needed. That's what I've done.

    By the way, clearRange() has an extra parameter to identify a particular range for the given field.

  • Anton Venter Profile Picture
    20,345 Super User 2025 Season 2 on at

    Have you tried the clearRanges method of the datasource?

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