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
Increase view resultset countIncrease view resultset count 

Count more than 10000 records

I have a scenario where I need to validate my created record Id is falls under a particular view of an Object. But my view has more than 10000 records where I need to validate my Id but StandardSetController getRecords() method is able to returning only 10000.

Please suggest me how can I increase this getRecords() returning record count.


Thanks in Advance.

jason.bradleyjason.bradley

You are reaching one of the governor limits. In order to total the number of records of that object, you need to use batch Apex. 
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm

 

Essentially, a batch Apex class has at least 3 main methods:

start

execute

finish

 

The generic body of a batch Apex class would look like this:

global class TestBatchApex implements Database.Batchable<sObject>{

	global final string query;

	global TestBatchApex(String query)
	{
		this.query = query;
	}
	
	global Database.queryLocator start(Database.BatchableContext context)
	{
		return Database.getQueryLocator(query);
	}
	
	global void execute(Database.BatchableContext context, List<SObject> scope)
	{
		
		List<Your_Custom_Object__c> customOBJs = (List<Your_Custom_Object__c>)scope;

		//Other code here
		//Other code here
		//Other code here		
	}
	
	global void finish(Database.BatchableContext context)
	{
		
	}
}

 

Increase view resultset countIncrease view resultset count

Hi Jason,

 

Thank you very much for your detailed explanation.

 

V