How to show a message/convey to the user that there are more than 10000 records when using StandardSetController?
Do I need to fire a separate SOQL just to count the number of rows and use the LIMT clause in the StandardSetController query to limit the rows? Is there a better way?
Also what is the use of the method getCompleteResult()
? I thought I could use this method to see if there are more than 10000 records in the StandardSet but when there are more than 10000 the page simply errors out with the message "Content cannot be displayed: Too many query locator rows: 10001".
Best Answer
If I take an org with over 50000
Account
records and run this snippet, I don't get any errors and I do get the expected output:And I also get the expected output if the
LIMIT
is at or below10000
.I tested these with API Version set all the way down to 10 on my
Apex Class
and 15 on myVisualforce Page
, and did not receive an error. Perhaps you open another query locator somewhere else on your page somewhere.