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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filter collection for ...
Power Apps
Unanswered

Filter collection for gallery by URL parameter

(0) ShareShare
ReportReport
Posted on by 91

Hi,  

 

I'm trying to do something that I thought would be simple enough, but apparently it isn't!  I have an app with an image gallery that is loaded from a collection to avoid any delegation issues.  From that app, users can share photos with colleagues via email.  At the minute it sends them as attachments within the email but now some of the file sizes are getting too big so I have to change it.

 

I have a flow set up which sends a link to the app with the IDs of the photos added onto the end of the link to the app as a URL parameter.  Whenever the user clicks the link it takes them to the right page but I'm having trouble then filtering the gallery by the IDs.  The IDs are separated by a comma so I know I need to use the split() function to split them up, I thought I could do something like ClearCollect(AllItems,Filter('Sharepoint library', ID in Split(ListIDs,",")) on screen visible, then reference the collection in the gallery but it doesn't seem to work.  

 

I feel like I'm missing a step somewhere, can anyone help?

 

 

Categories:
I have the same question (0)
  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    Hi!

     

    Have you tried setting your Split(ListIDs,",") to a variable so that you can check what its outputting?

     

    Also try not to name your collection to a protected name - AllItems is a property of Galleries and we should try not calling our collections or variables any of the 'standard' names that the Editor uses. Maybe use AllNAMEItems

     

    Cheers,

  • m3ngi3 Profile Picture
    725 on at

    Hi @bangorkeith, an example of how you are passing on the ID's as a URL parameter would help.

    Depending on how you are passing the URL parameter you need to:

    1 - get the parameter from the URL (nice blog here of Rik de Koning)

    2 - in case of multiple ID's then split the string with a separator that is URL supported

    3 - then for each splitted ID, collect the individual record to a new collection (ForAll function)

  • bangorkeith Profile Picture
    91 on at

    Hi,

     

    I have tried that, the list of IDs pull through into a list box.  Thankfully that end of it seems to be working, it's just filtering the collection and displaying it in the gallery which is the issue now.

     

    I didn't use the real collection name above, just wrote that as an example but thank you.

  • bangorkeith Profile Picture
    91 on at

    In fact, if I filter the gallery by the list box selected items then it works!  Though, then there would be delegation issues and of course the user would have to select the items from the listbox so not very practical but it's some sort of progress I suppose?

  • bangorkeith Profile Picture
    91 on at

    Hi Django, an example of the link passed from flow is below....

     

    https://apps.powerapps.com/play/[app address]?screenid=1&listids=2712,2711,2710,2709,

    The split function looks to work if I pass it to a variable and load it into a list box.  The ForAll function though I wasn't familiar with but it sounds like it might be the way to go, I'll read up on it!

  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    when you filter by the split list variable do you get the same results? Have you tried putting that split list into a gallery or a multi-select with the default selecting all items in it and then filtering by that?

    Just trying to think of ways to get around this 🙂

  • m3ngi3 Profile Picture
    725 on at

    That is great @bangorkeith!

    Django_2-1620207921752.png

     

  • m3ngi3 Profile Picture
    725 on at

    A second try @bangorkeith  because apparently the Forum does not like bullets... 

     

    ForAll(Split(Label7.Text,","),Collect(colListIDdata,ThisRecord))

     

     

    In your case:

      - label7 would be your Param("listids") expression

      - In the Collect expression you woulf want ThisRecord to be replaced with something like

     

    ForAll(Split(Label7.Text,","),Collect(colListIDdata,Filter('SharePoint List Datasource',ID=Value(Result))))​

     

    This will give a delegation warning because the Filter expression does not delegate the textual string to the ID column (even with the Value() expression added)...

     

    This means that a large number of list items (>500 or when configured >2000) will not give back all results.

    To have it delegated the complexity rises to to first create a collection with the right data type (ID column is an integer number and not a string as it comes from the Param() expression):

     

    ForAll(Split(Label7.Text,","),Collect(colListIDsAsValue,Value(Result)));ForAll(colListIDsAsValue,Collect(colListIDdata,Filter('SharePoint List Datasource',ID=Value)))

     

     

     

  • bangorkeith Profile Picture
    91 on at

    So, I have got the gallery to filter by the URL param using the ForAll function, but the delegation is an issue as there are well over 2000 items in the library.  

     

    I'm not sure I understand your second point about the delegation issue?  I tried to add all of the items in the sharepoint list to a collection as the screen loads and then filter that collection within the ForAll function but although it doesn't bring up any delegation errors it won't load items into the gallery beyond the delegated limit.  

     

    Bit stumped!

  • Verified answer
    m3ngi3 Profile Picture
    725 on at

    Hi @bangorkeith , my assumption was that the URL parameter would not include more than 500 (or 2000) ID's in the URL. If you will exceed this much items, I would not recommend this setup...

    My second code:

     

    ForAll(Split(Label7.Text,","),Collect(colListIDsAsValue,Value(Result)));ForAll(colListIDsAsValue,Collect(colListIDdata,Filter('SharePoint List Datasource',ID=Value)))

     

    does the following:

    1-splits the URL parameter string into separate objects (Result)

    2-then collects each split object (Result) in a collection colListIDsAsValue where it makes sure that the string is stored as an integer using the Value() expression

    (here my assumption was that it would be below the delegation limits)

    3-for every item in the first collection (colListIDsAsValue) it gets the record from your SharePoint list in a second collection (colListIDdata). This collect action is delegated which means that even if the SharePoint list has a million records --> it will get back every single record into the second collection.

    From this moment on, you can reference the last collection (colListIDdata) in the Power App to have all the data from the SharePoint list.

     

    However if at step 2 you will have more than 500 (or 2000) ID's in your URL.... this setup is not recommended and we should think of another approach or maybe even another tool (like Power BI)...

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard