function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC DummySFDC Dummy 

Batch class not Updated

Hi

I need to copy the field value from one object to other object.Both are look up relation ship.i have written a batch class for coping field from one to other automatically .
 
global class CopyStudtoAdr_Batch implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
     String query='SELECT ID,Closing_Balance__c,DailyUpdate__c FROM Debtors_Ledger__c';
     return Database.getQueryLocator(query);
   }
    global void execute(Database.BatchableContext BC, List<Debtors_Ledger__c> scope)
    {
      System.debug('Batch Class Started....');
      
      List<MasterCopy__c> adrToUpdate = [Select Id,Date__c,Closing_Balance__c ,Master__c from MasterCopy__c where Master__c in : Scope];

     Map<ID,Debtors_Ledger__c> stdMap = new Map<ID,Debtors_Ledger__c>(scope) ;
       
       // Loop to copy account Student to Address phone
       for(MasterCopy__c adr : adrToUpdate)
        {
         adr.Closing_Balance__c =  stdMap.get(adr.Master__c ).Closing_Balance__c;
         adr.Date__c=  stdMap.get(adr.Master__c ).DailyUpdate__c ;

         }
       if(adrToUpdate.size() > 0)
       update adrToUpdate;
      }
     global void finish(Database.BatchableContext ctx)
      {}
}

 
Chidanand MChidanand M
@ Project dummy,

Insted of writing the code inside the batch class, u can just run the logic inside the developer console. That might work for you. Check it out.