SHARE
TWEET

Untitled

a guest Jun 27th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* A simple batch Apex class to demonstrate updating a field on Opportunity
  2.  * Can be executed from Anonymous Apex using 2 lines:
  3.  * OpportunityBatch oppBatch = new OpportunityBatch();
  4.  * database.executeBatch(oppBatch);
  5.  */
  6. global class OpportunityBatch implements Database.Batchable<sObject> {
  7.     global Database.QueryLocator start(Database.BatchableContext BC) {
  8.         String query = 'SELECT Id,Name FROM Opportunity';
  9.         return Database.getQueryLocator(query);
  10.     }
  11.    
  12.     global void execute(Database.BatchableContext BC, List<Opportunity> scope) {
  13.          for(Opportunity opp : scope)
  14.          {
  15.              opp.Name = opp.Name + '-Updated';            
  16.          }
  17.          update scope;
  18.     }  
  19.    
  20.     global void finish(Database.BatchableContext BC) {
  21.     }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top