+ 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. 


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
              // Step 3: Set who the email is sent from
              // (Optional) Set list of people who should be CC'ed
              //List<String> ccTo = new List<String>();

              // 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.';
              // Step 5. Add your email to the master list

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);