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
yaramareddy radhikayaramareddy radhika 

System.StringException: Support for specifying both a day-of-week AND a day-of-month parameter is not implemented. I am getting this error for below code?

This is the batch Apex class which i am reffering in schedule apex class
==========================================================
global class BatchApexUpdate implements Database.Batchable<Sobject>{
    global string qe=[select Id,description from Account];
    
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator(qe);
    }
    global void execute(database.BatchableContext bc,List<Account> scope){
        for(Account a:scope){
          a.Description='Batch Test';
            a.Industry='sunderinfotech';
        }
        update scope;
    }
    global void finish(Database.BatchableContext bc){      
    
        OutboundEmail1 ob= new OutboundEmail1();
        ob.send();
    
    }
}


Schedule Apex class
====================

public class ScheduleExamp2 implements Schedulable{
    public void execute(SchedulableContext sc){
       
      BatchApexUpdate ba= new BatchApexUpdate();
}
}

Execution code in anonymous window   
===============================
ScheduleExamp2 se=new ScheduleExamp2();
string cron='0 0 16 2 1 2 2017';
ID jobid=system.schedule('batchapex', cron,se );

while executing this i am getting above error.
 
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for batch job
1) http://amitsalesforce.blogspot.com/2016/02/batch-apex-in-salesforce-test-class-for.html
2) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
ScheduleExamp2  se=new ScheduleExamp2();
string cron='0 0 0 16 2 ? 2017';
ID jobid=system.schedule('batchapex', cron,se );
User-added image

Let us know if above will help you
 
yaramareddy radhikayaramareddy radhika
May I Know What is the wrong in my cron Expression?I just entered the all the values without using special characters.Is there any rule compulsion using special character in cron expression
Amit Chaudhary 8Amit Chaudhary 8
You can try below code as well
ScheduleExamp2  se=new ScheduleExamp2();
string cron='0 0 0 16 2 1 2017';
ID jobid=system.schedule('batchapex', cron,se );

NOTE:- you need to pass 6 param but you was passing the 7
yaramareddy radhikayaramareddy radhika
Even though I passed 6 parameters also I am getting. same error and also I tried the one you suggested, the same error is displaying.
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for more information
1) http://www.chiragmehta.info/chirag/2009/11/12/salesforce-schedule-apex-to-run-at-any-time-interval/
2) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm

Issue is coming because you can not pass the both a day-of-week AND a day-of-month parameter.

So your exp can be below
string cron='0 0 0 ? 2 7 2017';
ID jobid=system.schedule('batchapex', cron,se );

Or
string cron='0 0 0 16 2 ? 2017';
ID jobid=system.schedule('batchapex', cron,se );