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
Kiranpreet KaurKiranpreet Kaur 

Count 5000+ records in salesforce.

I have a visualforce page and I want to show all the lead record and also its count on this VF page.

For the records I have used pagination and offset to retrieve the records and shown on the page.

But the problem is that I cannot show the total no of leads on this VF page as the records are 5000+.  It thorws an error as
TOO may rows 5001.
Ariel GorfinkelAriel Gorfinkel
Not sure that I fully understand your question.
You can use a count query (on your controller) to get the lead count, something like
SELECT count(Id) FROM Lead

Regarding showing all leads - pretty sure it can't be done unless you filter out some results (using dates or contacts or some other filter), or limit your query to 5,000 with
Select Id FROM Lead LIMIT 5000

If I didn't understand you properly, please clarify.
Kiranpreet KaurKiranpreet Kaur
Ariel Gorfinkel,

I have used SELECT count(Id) FROM Lead query in controller to get count of leads. But as my records are large in no 5000+. It shows error as:
Too many query rows: 50001

I don't want to user any filter as I want the exact no leads available in my org.
p pomi 3p pomi 3
i think
quary
list<integer> ll= new list<integer>();
select id,lastname from lead
ll.add(lead.size);