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
Samadhan Sakhale 3Samadhan Sakhale 3 

About Debug

Hi,
     I am trying to copy all cities from Student custom object in Address1 custom object into City__c field.all code working properly and code coverage also 100%
but the problem is that after running program cities not copied in Address table and i also trying to check program execution using System.Debug(''); but the statement not printed after executon in log my Code is here


global class CopyStudtoAdr_Batch implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
     String query='SELECT ID,City__c FROM Student__c';
     return Database.getQueryLocator(query);
   }
    global void execute(Database.BatchableContext BC, List<Student__c> scope)
    {
      System.debug('Batch Class Started....');
      //List<Address1__c> adrToUpdate = [Select id,StudentID__c,City__c from Address1__c where StudentID__c in : scope] ;
      //Set<String> setSturdentIds = new Set<String>();
      List<Address1__c> adrToUpdate = [Select Id,StudentID__c,City__c from Address1__c where StudentID__c in : Scope];

     Map<ID,Student__c> stdMap = new Map<ID,Student__c>(scope) ;
      
       // Loop to copy account Student to Address phone
       for(Address1__c adr : adrToUpdate)
        {
         adr.City__c =  stdMap.get(adr.StudentID__c).City__c ;
         }
       if(adrToUpdate.size() > 0)
       update adrToUpdate;
      }
     global void finish(Database.BatchableContext ctx)
      {}
}

Please check it and tell me Solution

Thanks,
Sam
rohitsfdcrohitsfdc
Hello Samadhan,
How are you executing this batch class?

And what is the problem exactly? the batch class is not executing, or the debug statements are getting logged in debug log
Samadhan Sakhale 3Samadhan Sakhale 3
Hi rohit,
i am running this class using excute anonymous window by calling the class like
CopyStudtoAdr_Batch b=new CopyStudtoAdr_Batch();
Database.excuteBatch(b);

it is running properly but it can not copy the records from student to address and the code coverage is 100% so tell me the solution 
for how can i improve my class?

and other problem is that System.Debug didnt print in log file.
Regards,
Sam
rohitsfdcrohitsfdc
Please share the debug log with me.
Samadhan Sakhale 3Samadhan Sakhale 3
       demug log is emty and i try to use it using System.debug that time also it cannot be generate sentence