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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Delegation on Search()...
Power Apps
Answered

Delegation on Search() function for SharePoint Files

(0) ShareShare
ReportReport
Posted on by 375

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

Categories:
I have the same question (0)
  • EddieE Profile Picture
    4,650 Moderator on at

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

  • BradonK Profile Picture
    375 on at

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

     

    Thanks

  • Verified answer
    EddieE Profile Picture
    4,650 Moderator on at

    @BradonK 

    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.

  • BradonK Profile Picture
    375 on at

    @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?

     

    Thanks

  • Pstork1 Profile Picture
    69,651 Most Valuable Professional on at

    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.

  • EddieE Profile Picture
    4,650 Moderator on at

    @BradonK 

    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.

  • BradonK Profile Picture
    375 on at

    @EddieE 

     

    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.

     

    Thanks

  • EddieE Profile Picture
    4,650 Moderator on at

    @BradonK 

    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.

  • BradonK Profile Picture
    375 on at

    @EddieE 

     

    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.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 379 Most Valuable Professional

#2
11manish Profile Picture

11manish 203 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard