Skip to content

Instantly share code, notes, and snippets.

@mtetlow
Last active January 3, 2016 12:38
Show Gist options
  • Save mtetlow/8463731 to your computer and use it in GitHub Desktop.
Save mtetlow/8463731 to your computer and use it in GitHub Desktop.
//Kick off with
Database.executeBatch(new batchUpdate(),50);
//Class like this
global class batchUpdate implements Database.Batchable<sObject> {
// This method returns a SOQL query locator containing the records
// to be iterated
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator([SELECT Id,Something__c FROM CustomObj__c]);
}
// The executeBatch method is called for each chunk of records returned from start.
global void execute(Database.BatchableContext BC, List<CustomObj__c> scope){
for(CustomObj__c obj : scope){
obj.Something__c = 'wat';
}
update scope;
}
global void finish(Database.BatchableContext BC){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment