Last active
August 29, 2015 14:17
-
-
Save victorabraham/935a610689bc1de5e480 to your computer and use it in GitHub Desktop.
Samples for different types of apex classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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