+ Start a Discussion
umesh bp 34umesh bp 34 

How to use batch apex?

How to use batch apex and schedule?
Ankit Gupta@ DeveloperAnkit Gupta@ Developer
Hi Umesh,

Please refer the bleow links:


Head In CloudHead In Cloud
Hi Umesh,

You can take help from below example: 
global class SearchAndReplace implements Database.Batchable<sObject>{

   global final String Query;
   global final String Entity;
   global final String Field;
   global final String Value;

   global SearchAndReplace(String q, String e, String f, String v){

      Query=q; Entity=e; Field=f;Value=v;

   global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator(query);

   global void execute(Database.BatchableContext BC, List<sObject> scope){
     for(sobject s : scope){
     update scope;

   global void finish(Database.BatchableContext BC){

Schedular class:
global class scheduledBatchable implements Schedulable {
   global void execute(SchedulableContext sc) {
      sendAndReplace b = new sendAndReplace(); 

Please let me know if this helps