victorabraham
3/14/2015 - 6:43 AM

Samples for different types of apex classes

Samples for different types of apex classes

public with sharing class Sample_ControllerExtension {

 private sObject mysObject;

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public Sample_ControllerExtension(ApexPages.StandardController stdController) {
        this.mysObject = (sObject)stdController.getRecord();
    }
}
global class Sample_BatchClass implements Database.Batchable<sobject> { 
String query;
 
 //Constructor of the batch class
 global Sample_BatchClass() {
  
 }
 
 global Database.QueryLocator start(Database.BatchableContext BC) {
  return Database.getQueryLocator(query);
 }

 global void execute(Database.BatchableContext BC, List<sobject> scope) {
  //Execute method where operations are done over different batches
 }
 
 global void finish(Database.BatchableContext BC) {
  //Finish method. It contains code that needs to be executed after all batches are complete
 } 
}