Announcements
Hi,
I have a gallery that pulls from a document library in SharePoint and searches it for keywords. I am getting a delegation warning because of this. Is Search not a delegable function? This library will have over 2000 items so needs to work above that.
What solutions are there for this?
Thanks
@BradonK
If you need to use Search(), then you will also need some sort of Pre-Filtering to get the filtered data down to 2,000 max.
For example, if your DocLib has Books, Magazines, DVDs, etc and each chunk of these would never have more than 2,000 items, you could create a MetaData column called Category that has these category names for each record/document. Then, users would pre-filter the DocLib before the Search() function was used.
@EddieE,
The files being brought in need to all be viewable in the gallery. So all items must be brought in. There is a filter box that you search for a specific name to narrow it down. Unfortunately, there is no way to pre-filter as all the files only have a name and no other identifier. Is there another way that is not affected by the delegation? If not, I could set up a flow that removes old files if need be.
The only other way would be to use StartsWith instead of Search - but I think that's not what you need/want. StartsWith is delegable but I'm unsure if it works on the {Name} field of a Doc Lib? I suspect it may not, meaning you'll need a separate Text field which replicates the file name to get StartsWith working.
If none of this suits, then you may need to look at using your Flow.
@EddieE
Thanks for the info. I looked into making a flow to sort it and it looks like it could work.
Out of curiosity, if I import the library as a collection with ClearCollect and then display that through the gallery and search the collection rather than the library directly, I don't get a delegation warning. Would that work for me? Or does ClearCollect still only import 2000 items?
StartsWith will work fine on the name field. But it will only find words at the beginning of the field, not in the middle. So StartsWith on 'Test' will fine 'Test Run' but not 'Run Test'. Search would find both.
Correct, ClearCollect() will only (at most) pull in 2,000 records. There are methods around that let you pull in more than 2,000 records but in your case you'll need some sort of MetaData field (either type Text or Number, the ID field doesn't work) that you can use to 'chunk off' your data into lots of less than 2,000. If you can do that, then you can create a collection >2,000 records.
Ok, well I can use a flow, that works fine. Is there any limit on galleries? Will they only show the first 2000 entries as well or do they display them all?
If all else fails, I will just set up a flow to archive old files.
Galleries can show all the items from your List or Library but they pre-fetch in batches of 100 records. If you setup a gallery and set it's items to your DocLib name you could see all your docs. It's just harder to find the ones you want - which is why most people use some sort of filtering.
If you scroll down that gallery, once you get to 100 items, PowerApps will pre-fetch the next 100 records - so the gallery will show 200 records, and so on.
If you add a label next to your gallery with this text
CountRows(Gallery1.AllItems)
You'll be able to see what I mean with the pre-fetching.
Ok thanks. Just wanted to make sure the gallery could keep fetching and wouldn't stop half way through or something.
Looks like I will go with a flow for the Search part though.
Appreciate all the help.
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.
Congratulations to our community stars!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
WarrenBelz 379 Most Valuable Professional
11manish 203 Super User 2026 Season 2
MS.Ragavendar 128 Super User 2026 Season 2