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
UjwalaUjwala 

Return list from batch class

Hi all,

i am working on requiremnt where many SOQL coming in picture. In one of function i am fetching data from custom object which hold record more than 50,000(another code has more soql also), then by iterating over fetched data i am preparing one list of strings which i will be using to display on VF. For this i am trying to write batch class i am doing fetch in Batch but i am not getting how to return list of strings as execute is of void type.
or can you suggest how i can achive this.  
Jolly_BirdiJolly_Birdi
Hello @Ujwala

For this you can use pagination, Refer these below links:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_sosc_pagination.htm

https://blog.jeffdouglas.com/2009/07/14/visualforce-page-with-pagination/

Please mark this as best answer if you find it useful.

Thanks
Jolly Birdi
UjwalaUjwala
Thanks jolly, 
but i am not able to relate this with my question. I want to write batch class which will return list of strings.
but i am not getting how exactly i can write code.?
Jolly_BirdiJolly_Birdi
Ujwala,

If you want to show the records at VF page then you need to use the standard class to fetch the records instead of batch class. In the same class you can use Offset with Pagination.

Thanks.
UjwalaUjwala
ok i dont know exactly but there is some limit for offset. 
and actually i want use batch class to avoid view state and max soql error.
 
Jolly_BirdiJolly_Birdi
I got your point Ujwala, But i dont believe with batch class we can show records in VF page.

For your problem, You can use filters on your VF page like date filter or something like that. with that you can use Offset under its limit.

Hope so it would be helpful.

Thanks
Jolly Birdi