ads

Wednesday, 27 July 2016

Batch Class In Salesforce






Batch Class Code :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
global class batchContactupdate implements Database.Batchable<sObject> {

global Database.QueryLocator start(Database.BatchableContext BC)
     {
    string Query='Select Name, Type from Contact';
     return Database.getQueryLocator(Query);
     }
       global void execute(Database.BatchableContext BC, List<contact> scope)
       {
        for (Contact a : Scope)
        {
            a.Description='----This Description is updated by Batch Class------';
        }
       update Scope;
       
       }
     
      global void finish(Database.BatchableContext BC) 
    {
    }
 }


Developer Console Code :-

1
2
batchContactupdate xyz = new batchContactupdate();
database.executebatch(xyz);



Apex Job :-




No comments:

Post a Comment