This blog post will be the first post of PowerApps tips series, in this series we will learn how to solve some PowerApps problem that faced us, or ow to solve some requirements.
We will learn how to select Next item of a gallery or DataSource and display this item in a form while clicking a button.
Assuming you have a gallery control named “Gallery1” that displays a collection of items from travel request SharePoint list, you want to get the next item from the gallery and display it in the form in the right, while clicking the next button. So if the current item is not the last item in the gallery, it will get the next item that has an ID greater than the ID of the current item. And if the current item is the last item in the gallery it will display the first item again.
- First thing you can create a variable that will contain the first item of the gallery in the OnVisible property of the screen.
- In the Onselect property of next button write this formula that will get the next item in the gallery ,
The next button is a PowerApps button to select next gallery item.
Set(CurrentGalleryItem, If( CurrentGalleryItem.ID = Last(Gallery1.AllItems).ID, First(Gallery1.AllItems), First(Filter(Gallery1.AllItems, ID > CurrentGalleryItem.ID)) ))
In this formula, “CurrentGalleryItem” represents the currently selected item in the gallery. The formula first checks whether the current item is the last item in the gallery using the “Last” function. If it is, the formula returns the first item in the gallery using the “First” function this will happen when reaching the last item of the gallery or your data source.
If the current item is not the last item in the gallery, the formula uses the “Filter” function to find the first item in the gallery that has an ID greater than the ID of the current item “that will represent the next item to the current selected item”.
- Set the item property of the form to be the CurrentGalleryItem to display the next item.
This is how to use PowerApps button to select next gallery item.
- Environment Variable In Power Platform With Examples
- How To Use PowerApps Coalesce Function Correctly?
- How Power Automate Add Working Days To Date?
- How Power Automate Exclude Weekends And Holidays Between Dates?
- How To Format Date In Power Automate?
- Power Automate Add Days To Date
- How To Use PowerApps DateDiff Function?
- PowerApps Parse JSON Example
- How To Use Switch Function In PowerApps?
- PowerApps Lookup Function Examples : Complete Tutorial
- Subscribe to Power Platform Geeks.
- Register to Saudi Arabia Power Platform User Group.
- Have a related question? Please ask it at deBUG.to Community.