Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Clear multiple ranges ...
Finance forum
Answered

Clear multiple ranges of same field on data source

Posted on by 250
Hello,
 
I have a scenario where I have added multiple ranges (as OR) on a datasource field using a multi select lookup.
I have used a loop to get the selected values and used:
qbds.clearRange(fieldNum(table, field));
for (int i = 1; i<=conLen(conValues); i++)
        {
            qbds.addRange(fieldNum(table,
                field)).value(queryValue(conPeek(conValues, i)));                    
        }
The problem with the clear range is that it is only removing one occurence of the field range and it is keeping all the other previous ranges on the field.
Is there any way to clear all occurences of the field range?
  • Jason0810M Profile Picture
    Jason0810M 250 on at
    Clear multiple ranges of same field on data source
    Thanks Martin.
    The rangeCount would not be feasible to use for me as there are many ranges on several other fields.
    I've tried the findRange with the while loop and it works perfectly fine.
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 228,552 Most Valuable Professional on at
    Clear multiple ranges of same field on data source
    Yes, it is possible. You could utilize the second parameter of clearRange() (_occurrence), but I think it's easier to simply call clearRange() with a single parameter repeatedly.
     
    You can either use a for loop (rangeCount() tells you how many times you need to run it), you a while loop checking if there is any range remaining (by utilizing findRange()).

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,552 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,552 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans