Not sure what the actual question is but I propose that you have a look into following links. The interface for batch apex class is Database.Batchable<sObject> or for example Account batch it would be Database.Batchable<Account> https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex/async_apex_batch https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_database_batchable.htm
Batch Apex is usually used together with schedule. Check these resources for more info: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_system_schedulable.htm#apex_interface_system_schedulable https://trailhead.salesforce.com/content/learn/modules/asynchronous_apex/async_apex_scheduled
To use Batch Apex, we must implement Database.Batchable interface, below are the methods which we use: 1)Start 2)Execute 3)Finish
Start: This method is called at the beginning of the batch apex job.This method will return either an object of type Database.QueryLocator or an iterable that contains the records or objects passed to the job.This method will collect records on which the operation will be performed. These records are divided into batches and pass those to execute method.
Execute: This method contains the set of instructions which we want to perform on those records which we retrieved from the Start method.
Finish: This method gets executed after all the batches are processed. We use this method to send email to inform them about the job completion.
Below is the example:
global class AccountBatchUpdate implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext BC) { String query = ‘SELECT Id,Name FROM Account’; return Database.getQueryLocator(query); }
Not sure what the actual question is but I propose that you have a look into following links. The interface for batch apex class is Database.Batchable<sObject> or for example Account batch it would be Database.Batchable<Account>
https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex/async_apex_batch
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_database_batchable.htm
Batch Apex is usually used together with schedule. Check these resources for more info:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_system_schedulable.htm#apex_interface_system_schedulable
https://trailhead.salesforce.com/content/learn/modules/asynchronous_apex/async_apex_scheduled
Regards,
Mkr
To use Batch Apex, we must implement Database.Batchable interface, below are the methods which we use:
1)Start
2)Execute
3)Finish
Start: This method is called at the beginning of the batch apex job.This method will return either an object of type Database.QueryLocator or
an iterable that contains the records or objects passed to the job.This method will collect records on which the operation will be performed.
These records are divided into batches and pass those to execute method.
Execute: This method contains the set of instructions which we want to perform on those records which we
retrieved from the Start method.
Finish: This method gets executed after all the batches are processed. We use this method to send email to inform them about the job completion.
Below is the example:
global class AccountBatchUpdate implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext BC) {
String query = ‘SELECT Id,Name FROM Account’;
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope) {
for(Account a : scope) {
a.Name = a.Name + ‘******’;
}
update scope;
}
global void finish(Database.BatchableContext BC) {
}
}
To learn more: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi