Skip to content

Instantly share code, notes, and snippets.

@victorabraham
Last active August 29, 2015 14:17
Show Gist options
  • Save victorabraham/935a610689bc1de5e480 to your computer and use it in GitHub Desktop.
Save victorabraham/935a610689bc1de5e480 to your computer and use it in GitHub Desktop.
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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment