293
Views
5
Comments
How to get the next row from the database
Question
Application Type
Reactive

How to get the next row from the database 

if i have screen details ,in this screen i have two buttons (next and previous )

i need when i click on next  fetch from next row  for example  ,if i have id = 2  and the next row in an entity have id = 5

i need when i click on next  fetch from next row which id = 5 ,And vice versa when  i click on previous  .

How can I do that ?

2021-11-18 18-03-41
AJ.

Hello @andrew mahfouz,

Please review this post. The solution has an oml attached as well.

Another way of doing a list traversal is also discussed here. This post is a more recent one and I do prefer this approach.

Regards,

AJ

2025-03-19 01-45-51
Sandeep Kumar Kolli

Hello @andrew mahfouz ,

--In OnInitialize It's better to get the Identifers and store them in a list

--Create a Local Variable and assign the first element from the above list [Id]

--Add filter to the aggregate in which you're getting a particular record from the database[aggregate.Id = Id] 

--When you click on Next Button, Add a Client action and find the index of the Id[local variable] and get the Index+1 element from the list and assign it to the Id, so that Id will be changed and aggregate will get refreshed and fetches the next question

--You can do in same way for back button as well, but need to decrement the Index

--Make sure to stop the flow when you're at first element[stop back click] , at last element[stop Next click]


Hope this helps, if not I'll work on it and can provide you an working sample.


Thanks,

Sandeep.

UserImage.jpg
Shahed Saqlawi

 Can you gave me any OML file about what you take? 

2021-10-09 07-57-44
Stefan Weber
 
MVP

Hi, 

to add previous and next record options based on an autonumbered integer id i would recommend using an advanced query which fetches the current record and the next and previous identifiers. See the OML on how to do that. Basically the query fetches the record by its id and adds to subqueries for retrieving next and previous ids.

Best

Stefan

PrevNext.oml
UserImage.jpg
Aishwarya R

Hi,


I am posting my OML ,May be it will be beneficial for someone.Thanks!

EmployeeForm.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.