Thursday, June 9, 2016

Simple Batch Apex example that extend Schedulable Interface In the Batch Apex in Salesforce

Apex Code:

global class batchAccountUpdate implements Database.Batchable<sObject>,schedulable {
    global Database.QueryLocator start(Database.BatchableContext BC) {
        String query = 'SELECT Id,Name FROM Account';
        return Database.getQueryLocator(query);
    }
   global void execute(SchedulableContext sc) {
      batchAccountUpdate b = new batchAccountUpdate(); 
      database.executebatch(b);
   }
    global void execute(Database.BatchableContext BC, List<Account> scope) {
         for(Account a : scope)
         {
             a.Name = a.Name + 'Updated';            
         }
         update scope;
    }   
    
    global void finish(Database.BatchableContext BC) {
    }
}

2 comments:

Common interview questions for Salesforce developers

Name three Governor Limits .                                                                                    Description Synchronous ...