function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sam1980Sam1980 

SOQL to show next and previously added data

How to  write SOQL to show next and previously added case data. How can i fetch record according to created date. What would be the SOQL to fetch data.
Please check  below.

User-added image
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
Hi,

You can add order by createddate clause to your soql.
list<case> lstcase = new list<Case>([select id, subject from case order by createddate desc limit 100]);
This will hold the orderd list of case.

Now you can use list.get() mrthod to get the reuired record
integer nextCounter = 0;

lstCase.get(nextCounter);
nextCounter = nextCounter+1; //update nextCounter value
Thanks,
N.J

AshlekhAshlekh
Hi,

If you want to use pagination on your page then refer below link

http://forceguru.blogspot.in/2011/04/pagination-in-salesforce.html