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
Ashutosh RajputAshutosh Rajput 

Schedule Query

Schedule QueryCan anyone help me out to solve this Error i would be very thankful for that.
1) When i schedule my schedule class from apex schedule , I am getting this error
-An error has occurred in the following section: [Exception, InvalidScheduledApexClass]. Salesforce.com has been notified of this error
Prabhat Kumar12Prabhat Kumar12
Found some usefull link. 

http://blog.jeffdouglas.com/2013/01/17/schedule-apex-exception-no-apex-classes-found/
http://forcemonkey.blogspot.in/2010/01/what-causes-invalid-apex-classes.html

Let me know if it does not work.
 
Ashutosh RajputAshutosh Rajput
Thanks Prabhat, But my class is active and there no coverage issue, when i schedule the class from apex schedule particular error come that i have mentioned above
Prabhat Kumar12Prabhat Kumar12
Please post your complete code.
Ashutosh RajputAshutosh Rajput
Global class scheduleforAccount implements Schedulable{
public List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
public List<String> sendTo = new List<String>();

global void execute (SchedulableContext SC){
    
 for(account acc : [SELECT id, Contact_Bill_Due_Date__c, Testing_Checkbox__c, (Select Id, SARA_Contact_Category__c ,Email FROM contacts) from account WHERE Contact_Bill_Due_Date__c =: date.TODAY()-5 OR Contact_Bill_Due_Date__c =: date.today()+1]){
     for(contact con : acc.contacts) {
     if(acc.Testing_Checkbox__c == true){
         if(con.SARA_Contact_Category__c == 'Primary Institution contact' && con.SARA_Contact_Category__c == 'Billing rep'){
             Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
              
              // Step 2: Set list of people who should get the email
              
              sendTo.add(con.Email);
              mail.setToAddresses(sendTo);
    
              // Step 3: Set who the email is sent from
              mail.setReplyTo('sirdavid@bankofnigeria.com');
              mail.setSenderDisplayName('Salesforce');
    
              // (Optional) Set list of people who should be CC'ed
              //List<String> ccTo = new List<String>();
              //ccTo.add('business@bankofnigeria.com');
              //mail.setCcAddresses(ccTo);

              // Step 4. Set email contents - you can use variables!
              mail.setSubject('Expired Date');
              String body = 'Dear ' + con.FirstName + ', ';
              body += 'Due Date is Expired Now.';
              body += 'Please Check That.';
              
              mail.setHtmlBody(body);
    
              // Step 5. Add your email to the master list
              mails.add(mail);
              mails.clear();
         }
         }
     }
 }
                 Messaging.sendEmail(mails);
}

}
Prabhat Kumar12Prabhat Kumar12
Are you scheduling your class through code. If yes then Please use this.
//For hourly job
String CRON_EXP = '0 0 * * * ?';
   scheduleforAccount sch = new scheduleforAccount();
   system.schedule('Schedule', CRON_EXP, sch);