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
Vaibhav ShettiVaibhav Shetti 

What is the best way to get ListViews and related filters?

I need to fetch ListViews and related filters, say for Account object. I know StandardSetContoller has methods - getListViewOptions() and getFilterId() methods which are helpful. However, the maximum record limit for StandardSetController is 10,000 records. In my case there are records more than 10,000. How do I implement this so that I can handle records more than 10,000?
Best Answer chosen by Vaibhav Shetti
Shruti SShruti S
Unfortunately I don't think there is a way to do this. The limitation of the StandardSetController is a hard and fast limit of 10K. We cannot do anything.

I think you will have to use the REST API to access the SOQL behind a list view and build our own UI.

Here is an Apex Class - https://github.com/shrutis22/Record-Lookup/blob/master/src/classes/ListViewAPI.cls that I used a long ago to accomplish this.

Using the Apex Class + REST API, you can get the SOQL query behind the LIST VIEW. You can then use OFFSET and LIMIT to show more records.

All Answers

PawanKumarPawanKumar
have you tried this property <apex:page readOnly= "true"/>?. It will allow you 1lacs records.
Shruti SShruti S
Unfortunately I don't think there is a way to do this. The limitation of the StandardSetController is a hard and fast limit of 10K. We cannot do anything.

I think you will have to use the REST API to access the SOQL behind a list view and build our own UI.

Here is an Apex Class - https://github.com/shrutis22/Record-Lookup/blob/master/src/classes/ListViewAPI.cls that I used a long ago to accomplish this.

Using the Apex Class + REST API, you can get the SOQL query behind the LIST VIEW. You can then use OFFSET and LIMIT to show more records.
This was selected as the best answer
Vaibhav ShettiVaibhav Shetti
@Shruti Your code will solve my issue. However, I had another question. The query from listViewDescResp.query would be string. So how do you execute it - Database.query() or Database.getQueryLocator()? And how do you use OFFSET with these? Can you post a code snippet?
Vaibhav ShettiVaibhav Shetti
@Shruti thank you for your code. It helped.
Debasish Paul 23Debasish Paul 23
Hi,
  Wlile I am trying to access the apex written by Shruti either from Visualforce or from LWC Component I am getting unauthorized Access to end point. 
Error Details:
16:30:16.0 (62355232)|CALLOUT_RESPONSE|[83]|System.HttpResponse[Status=Unauthorized, StatusCode=401] 16:30:16.0 (62462969)|
6:30:16.0 (64473927)|FATAL_ERROR|System.JSONException: Malformed JSON: Expected '{' at the beginning of object

Any help would be highly appeciated.