cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
samhegartyunsw1
Helper I
Helper I

Navigate to next filtered gallery item

I've created a gallery based on a filtered collection.  The gallery item references a Variable I've setup in order to filter e.g. 

UpdateContext({FilteredList:Filter(NominationCollection, NominationType = "team" || NominationType = "individual" 
)});

What I now want to do is have someone navigate to the next item in the gallery once they've clicked through to view the item details. This would save them having to go back to the main gallery screen then click on the next item manually.

 

Is there a way to do this? I'm thinking if it somehow gave each item in the gallery a number in order which it appears and then setup a button to load the next item when selected.

 

Thanks.

9 REPLIES 9
v-monli-msft
Community Support
Community Support

Hi @samhegartyunsw1 ,

 

I think this cannot be achieved so far, as the context variable would be different numbers of records according to the filtered result.

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-monli-msft would there be a way when I apply the filter to update a column to give each record a number (starting at 1 then going sequentually) so there's something to reference? Then I could update a button to move to the +1 record?

rebeccas
Community Champion
Community Champion

I'm not sure if you can adjust this for yours but I have one I do that goes to next item when they click the next button in my gallery. 

 

My gallery is tied to a SharePoint List which uses an auto ID by default.

 

Screen OnVisible = Set(varSelected, 1)

Next button OnSelect= Set(varSelected, ThisItem.ID + 1)

                                  Or = Set(varSelected, varSelected+1) -- If you want them to not have the option to go out of order.

 

Then for what I want to show it has =If(varSelected=ThisItem.ID, true, false)

Thanks for the suggestion @rebeccas. In my case, because I'm filtering a collection which means I can't utilise an auto numbering system.

 

I'm really surprised PowerApps hasn't built nextItem and previousItem commands that let you do this as it's a common thing to do.

If your using a collection instead of a data source you should (in theory...I haven't done this yet) be able to just add a column into your collection and create a auto number in that column. 

 

I usually don't work with collections that aren't tied to a data source but something like this should work for doing the auto number:

 

https://powerusers.microsoft.com/t5/General-Discussion/AutoNumber/td-p/184207

 

Good luck!

jvanrossum
Advocate IV
Advocate IV

This example takes the next item from the filtered or sorted gallery which is used for a next button:
PowerAppsNext06.png

Hi @jvanrossum /Joost,

 

I saw your blogpost and I would like to say thank you for posting your solution.💪

 

However, I have tried it myself but unfortunately do not succeed, as I run into the following 'issue':  "invalid argument type" within Step 3 at line 6/7 of the code (please see the attached image). 

My SP List is called "Biosurgery" and instead of using a unique product key I am using an ID that I created within the SPlist.

 

Do you have an idea how to fix this? 

 

Thank you and best regards

Jan-Hinrich

 

Powerapps Issue Invalid argument.png

 

 

JHL
Advocate II
Advocate II

Hi @jvanrossum ,

 

I was able to resolve it myself. Made some mistakes in the syntax.

You are the man for posting this solution. I have been looking for something similar for a long time. So once more, thank you!

 

Best regards

JH

Hi,

 

Found a solution which is working for me.

 

  1. your SharePoint list must have a ID field which is getting auto generated

 

  1. You can create a Collection using clearcollect function & filter as per your requirement.

 

  1. Use lookup function you can go to next & previous record

3.i on load you can set the item proper to lookup where coniditin will be ID>0 this will ensure that first record of the collection is displayed in the list

3.ii create a next button where lookup will have condition like "ID>current record ID"

3.iii create a previous button where lookup will have condition like "ID<current record ID"

 

Trust this solves your query..

 

 

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (2,675)