I have a display form that I want to add a button to take the user to the next record from the list. I am new to powerapps and not sure how to accomplish this.
I have a display form that I want to add a button to take the user to the next record from the list. I am new to powerapps and not sure how to accomplish this.
Hi @RobinHan
Good point.
Approach 1:
You can do this approach, but this has a delegation limit
Previous button
UpdateContext({varRecord:First(Filter(Sort(MyDataSource,ID,SortOrder.Descending),ID < varRecord.ID))})
Next Button
UpdateContext({varRecord:First(Filter(MyDataSource,ID > varRecord.ID))})
Approach 2:
Get the next/previous item by Created date. This will not work if your items are created in bulk at the same time
Previous Button
UpdateContext({varRecord:First(Filter(Sort(MyDataSource,ID,SortOrder.Descending),Created < varRecord.Created))})
Next Button
UpdateContext({varRecord:First(Filter(MyDataSource,Created > varRecord.Created))})
Approach 3:
You can have a helper column that is a number type. Everytime you patch, you patch a sequential number in that column. This will not have the delegation warning. Let say we call our helper column Sequence.
Previous Button
UpdateContext({varRecord:First(Filter(Sort(MyDataSource,ID,SortOrder.Descending),Sequence < varRecord.Sequence))})
Next Button
UpdateContext({varRecord:First(Filter(MyDataSource,Sequence > varRecord.Sequence))})
you are absolutely right. That was also my first thought
Hi, thanks. but how about if the data source record were deleted, so the record ID will not be continue.
then this way via the ID +1 or -1 should be not work perfectly. any other better solution?
@TimothyTrimble I found another way to achieve this same effect. its a bit more work but it may be due to the fact that my gallery is filtered, not sure but here it is.
My Gallery has a button/Icon with OnSelect property set to Select(Parent) and navigate to the screen with the edit form.
The Edit form's screen has it's On Visible property set to Set(varRecord, MyGallery.Selected.ID)
On my next button/icon I have on the OnSelect property
Set(varRecord,Min(Filter(MyGallery.AllItems,ID > varRecord),ID))
and on the my back button/icon' OnSelect property Set(varRecord,Max(Filter(MyGallery.AllItems,ID < varRecord),ID))
And lastly, my item property on my form is set to LookUp(MyDataSorce ID = varRecord)
Late reply. But did you put varRecord in the Items property of your form?
Same here, what step is missing?
Is there any other action needed? I added two icons to the top of my details form and added the functions. Nothing happens when selected.
Hi @ksmith23
For example, if you have a gallery for your data source in the same screen, you can have a button in a gallery and on its OnSelect property, you can set a variable named varRecord like:
UpdateContext({varRecord:ThisItem})
How do I set the variable for the form on the Items? I am not sure of the formula I need to use.
Hi @ksmith23
Here's a start. You can have your selected record as a variable (for this example let's call it varRecord). Then in your Next button you can add a function to go over the next record.
UpdateContext({varRecord:LookUp(YourDataSource,ID=varRecord.ID + 1)})
WarrenBelz
146,702
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,015
Most Valuable Professional