• Nagaraj Chigi 5
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi

I updated contact name everyday means only those records modified same day that records only updated i wrote the batch apex but it's not work properly.


global class batchContactUpdate implements Database.Batchable<sObject> {
        
        
    global Database.QueryLocator start(Database.BatchableContext BC) {
        Date d=date.today();
        System.debug('d');
        String query = 'SELECT Id,LastName,Phone FROM Contact where LastModifiedBy - d';
        return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext BC, List<Contact> scope) {
         for(Contact con : scope)
         {
             con.LastName = con.LastName + 'Updated';            
         }
         update scope;
    }   
    
    global void finish(Database.BatchableContext BC) {
    }
}


Regards,
MPL