Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* A simple batch Apex class to demonstrate updating a field on Opportunity
- * Can be executed from Anonymous Apex using 2 lines:
- * OpportunityBatch oppBatch = new OpportunityBatch();
- * database.executeBatch(oppBatch);
- */
- global class OpportunityBatch implements Database.Batchable<sObject> {
- global Database.QueryLocator start(Database.BatchableContext BC) {
- String query = 'SELECT Id,Name FROM Opportunity';
- return Database.getQueryLocator(query);
- }
- global void execute(Database.BatchableContext BC, List<Opportunity> scope) {
- for(Opportunity opp : scope)
- {
- opp.Name = opp.Name + '-Updated';
- }
- update scope;
- }
- global void finish(Database.BatchableContext BC) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement