You need to sign in to do that
Don't have an account?
Aman Wadhwa 8
scheduale apex problem
I want to run a schedule apex after every 2 years is it possible to do so and if yes how to do it.
Thanks in advance.
Thanks in advance.
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Scheduling through cron expression, is not possible for every 2 years. instead you can try with process builder with scheduled action if there is a custom object to store the next scheduled date and triggering event.
If scheduling is not based on record detail, or if the object has more transaction frequently and not able to consider the filters, then
Create a custom setting to hold the next scheduled date, and create a record with 2 years later date.
Schedule a apex class daily, to query the custom setting record's next scheduled date = today,
if yes, do the <processing> and update the next scheduled date = today+2 years.
If custom setting record's next scheduled date not equal to today, then skip the <processing>.
If it solves the problem, mark it as resolved.
Thanks
Seems this could be possible.
You can use cron expression and may be set specific date and month and year .
Please find the references on how we can use the cron expressions and scheduler simultaneously.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
https://www.forcetalks.com/blog/using-cron-expression-in-salesforce/
Hope this helps.
Greetings!
Can you please check the cron expression to schedule the apex class for every year and try by adding 2 to the year in the below expression:
https://salesforce.stackexchange.com/questions/247663/schedule-apex-class-to-run-every-year
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
0 0 0/2 1/1 * ? *
Here is an example
If you use the following chron string for your scheduled job, it will run every 4 hours (at set times) Monday through Friday.
If you wanted it to run every day, you would just change it to
Let me know if this helps