+ Start a Discussion
Priya AakankshaPriya Aakanksha 

birthdays emails should be automatically triggered to the customer global class BirthdayNotificationBatchClass implements Database.Batchable<sObject>,schedulable{ global Database.querylocator start(Database.BatchableContext bc){ String query= 'SELECT

This is my batch class so that i was facing an error regarding the trigger firing like 
Class BirthdayNotificationBatchClass must implement the method: void Database.Batchable<SObject>.execute(Database.BatchableContext, List<SObject>)
Class BirthdayNotificationBatchClass must implement the method: void System.Schedulable.execute(System.SchedulableContext)

Please help me out from this 
Priya AakankshaPriya Aakanksha
global class BirthdayNotificationBatchClass implements  Database.Batchable<sObject>,schedulable{
 global Database.querylocator start(Database.BatchableContext bc){
  String query= 'SELECT Id, Name, email__c,birthday__c FROM account__c';
  return Database.getQueryLocator(query);
 }

global void execute(Database.BatchableContext bc, List<account__c> acclist){
    
    set<id> accids=new set<id>();
    for(account__c acc : acclist)
 {
      accids.add(acc.id);
 }
    {
   date thisdate=system.today();
   integer sysday=thisdate.day();
   integer sysmonth=thisdate.month();
   string dayandmonth=sysday+'/'+sysmonth;
   Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
   List<String> toAddresses = new List<String>();
   toAddresses.add(iteratorUser.email__c);
   email.setToAddresses(toAddresses);
   List<String> ccAddresses = new List<String>();
   ccAddresses.add('priyaaakanksha28@gmail.com');
   email.setCcAddresses(ccAddresses);
   email.setSubject('Happy Birthday. Have a blast — Birthday Reminder!');
   String message = 'Happy Birthday';
   email.setHtmlBody(message);
   Messaging.sendEmail(new Messaging.SingleEmailMessage[]{email});
 }
}

 global void finish(Database.batchableContext bc)
 {
 }
}


This is my Code Please help me out 

Class BirthdayNotificationBatchClass must implement the method: void Database.Batchable<SObject>.execute(Database.BatchableContext, List<SObject>)
Class BirthdayNotificationBatchClass must implement the method: void System.Schedulable.execute(System.SchedulableContext)

These are my errors
Kancharla ChakravarthyKancharla Chakravarthy
Please use the below code and add the filters for a date check
 
global class BirthdayNotificationBatchClass implements Database.Batchable<sObject>, schedulable {
    
    global BirthdayNotificationBatchClass() {
    }
     
    global Database.querylocator start(Database.BatchableContext bc){
      String query= 'SELECT Id, Name, email__c,birthday__c FROM account__c';
      return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext bc, List<account__c> acclist){
        
        List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
        
        for(account__c acc : acclist){
             
              //Do the date comparision if the birthday equals today or else you can query the records in the start method where birth day equals today
                              
               Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
               List<String> toAddresses = new List<String>();
               toAddresses.add(acc.email__c);
               email.setToAddresses(toAddresses);
               List<String> ccAddresses = new List<String>();
               ccAddresses.add('priyaaakanksha28@gmail.com');
               email.setCcAddresses(ccAddresses);
               email.setSubject('Happy Birthday. Have a blast — Birthday Reminder!');
               String message = 'Happy Birthday';
               email.setHtmlBody(message);
               mailList.add(email);
        }
  
       Messaging.sendEmail(mailList);
    }

    global void finish(Database.batchableContext bc){
    
    }
    
    global void execute(SchedulableContext SC) {
        database.executebatch(new BirthdayNotificationBatchClass());
    }
    
    global static void start(integer hour){
         string jobName = 'job name';
         if (hour == 0) database.executebatch(new BirthdayNotificationBatchClass());
     else {
         jobName = jobName += ' - ' + datetime.now().format();
         string cron = '0 0 ' + string.valueof(hour) + ' * * ?';
         system.schedule(jobName, cron, new BirthdayNotificationBatchClass());
     }
     }
}

Please choose as best answer if the above code works for you. It will help others to find the best answers