You need to sign in to do that
Don't have an account?
Cloud_Dragon
Batch Apex Scheduler
Hi Folks,
I have a scenario where my batch apex class should run every 4th working day of month. Any thoughts how can this be done.
Any help would be greatly appreciated - I am kinda stuck on this for a while .. :(
I have a scenario where my batch apex class should run every 4th working day of month. Any thoughts how can this be done.
Any help would be greatly appreciated - I am kinda stuck on this for a while .. :(
Under Setup | Develop | Apex Classes, you can click on Schedule Apex, select the batch apex class you want to schedule, and you can choose to either run it on the 4th day (not exactly working day) of every month. You can also choose to run it on, for example, the 1st Thursdayday of every month or the 3rd Monday of every month. There is no option to select only working days.
You can probably try setting up the day of the month in your code itself, using some login like this.
string day = 4,
if(day is saturday){day=day+2}
if(day is sunday){day=day+1}
Then use this day in the cron syntax that is used in the scheduled apex class. I have not tried it myself, but this looks like the only workaround. Apologies for the lazy syntax, but here is a link you can use for scheduled apex example: http://blog.deadlypenguin.com/blog/2012/05/26/scheduled-actions-in-salesforce-with-apex/
Thanks,
Shashank
All Answers
Under Setup | Develop | Apex Classes, you can click on Schedule Apex, select the batch apex class you want to schedule, and you can choose to either run it on the 4th day (not exactly working day) of every month. You can also choose to run it on, for example, the 1st Thursdayday of every month or the 3rd Monday of every month. There is no option to select only working days.
You can probably try setting up the day of the month in your code itself, using some login like this.
string day = 4,
if(day is saturday){day=day+2}
if(day is sunday){day=day+1}
Then use this day in the cron syntax that is used in the scheduled apex class. I have not tried it myself, but this looks like the only workaround. Apologies for the lazy syntax, but here is a link you can use for scheduled apex example: http://blog.deadlypenguin.com/blog/2012/05/26/scheduled-actions-in-salesforce-with-apex/
Thanks,
Shashank