+ Start a Discussion
Saikishore Reddy AengareddySaikishore Reddy Aengareddy 

Batch Apex Job Error!

Hello All-


I scheduled the following schedulable class and I am getting a strange error...


|EXCEPTION_THROWN|[18]|System.StringException: Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.




global class ICG_FixDuplicateLeadsProcessorExtends implements Schedulable{
    // global method - execute
    // Call Batch method
    global void execute(SchedulableContext sc) {
        //  Instantiate class
         ICG_FixDuplicateLeadsProcessor FixDuplicateLeadsProcessor = new  ICG_FixDuplicateLeadsProcessor();
        String seconds = '0'; //Execute at Zero Seconds
        String minutes = '30'; //Execute at every 30th minute of hour
        String hours = '*'; // Execute Every Hour
        String dayOfMonth = String.valueOf(Datetime.now().day()); // Execute on current Day of the current Month
        String month = String.valueOf(Datetime.now().month()); //Execute current Month
        String dayOfWeek = '';
            dayOfWeek = String.valueOf((Datetime.now().day()/7));
            dayOfWeek = String.valueOf(Datetime.now().day());
        String year = String.valueOf(Datetime.now().year()); //Execute only for year 2011

    //Seconds Minutes Hours Day_of_month Month Day_of_week optional_year
        String sch = seconds + ' ' + minutes + ' ' + hours + ' ' + dayOfMonth + ' ' + month + ' ' +dayOfWeek+ ' ' + year;
    //String sch = '0 30 * 5 5 ? 2011';
system.debug('Scheduled time string---->>>>>'+sch);
system.schedule('Fix Duplicate Leads', sch, FixDuplicateLeadsProcessor);


If I remove the "dayofWeek" from the string sch i get the following error...

EXCEPTION_THROWN|[18]|System.StringException: Day-of-Week values must be between 1 and 7


Any thoughts?





you have to use the day of week for sure... dont remove that ..this is not optional.



just follow this 





Saikishore Reddy AengareddySaikishore Reddy Aengareddy

Hello Kiran,


I agree with you but my question is why is it giving me the error "System.StringException: Support for specifying both a day-of-week AND a day-of-month parameter is not implemented." when i specify all the parameters as it was specified in the documentation?


Any suggestions/Ideas?



Prafull G.Prafull G.

only removing dayOfWeek will not work.


try below line


String sch = seconds + ' ' + minutes + ' ' + hours + ' ' + dayOfMonth + ' ' + month + ' ? ' + year;





The docs are obviously wrong in this case.  While the standard of documentation is generally good, its not perfect, so it may be that you used to be able to specify both and now you can't.


In *nix world the behaviour of cron in this scenario differs quite a bit - some ignore the day of week, some or the values together.  


The most used java implementation (the quartz scheduler, which may be what SF use) requires that one of these values is specified as a '?'.