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

Announcements

No record found.

News and Announcements icon
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
    239,118 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,678 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Basit Profile Picture

Basit 1

#1
GL-01081504-0 Profile Picture

GL-01081504-0 1

#1
Roya Profile Picture

Roya 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans