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
INDY ONEINDY ONE 

Could some one help with:

Using batch Create a scheduler which will run midnight daily. The scheduler will  check for duplicate Accounts and if find any then it will merge the accounts and relate its child records(Contacts,Opportunity and Cases) to the one which is existing.
agrawal mukulagrawal mukul
Hi Indy,

At schedular class you cannot write a SOQL query and execute, It has to be written at Batch start method.
To schedule a class at midnight daily GOTO -> setup -> Schedule apex -> select all days and time and schedule it. 

or use below scheduler  class

public  class scheduleBatchclass implements Schedulable {
  
    
    
    public string scheduleFamBatchclass2() {
        scheduleBatchclass reminder = new scheduleBatchclass();
        String sch = '0 0 24 1/1 * ? *';        
        return System.schedule('execute batch class', sch, reminder);
    }
    
 public void execute(SchedulableContext sc) {
      BatchClass b = new FBatchClass(); 
      database.executebatch(b);
   }
}

if it helps mark as best answer.

Thanks,
Mukul