You need to sign in to do that
Don't have an account?

How to delay specific batch job execution
Hi,
I have a scheduler class which reads list of objects (object1, object2, object3) and invokes batch class for each object.
Batchclass bc = new Batchclass(object1)
batchJobId= database.executeBatch(bc,1000);
I would like to delay the batch job execution if object is 'Contact' . CAn you please share how it needs to be done ?
I have a scheduler class which reads list of objects (object1, object2, object3) and invokes batch class for each object.
Batchclass bc = new Batchclass(object1)
batchJobId= database.executeBatch(bc,1000);
I would like to delay the batch job execution if object is 'Contact' . CAn you please share how it needs to be done ?
Please, try like this. It will delay 5 seconds, and If you want to delay 10 sec, you should add 10 seconds in while loop.
batchclass bc = new batchclass();
Id batchJobId = database.executeBatch(bc,1000);
datetime start = system.now();
while(system.now() < start.addseconds(5)){}
System.debug('wait start time :'+ start);
System.debug('Wait end time :'+ start.addseconds(5));
If, it helps you. pls, mark it as a best answer.
I see you also posted on https://salesforce.stackexchange.com/questions/389000/how-to-delay-specific-batch-job-execution. Please share your usecase.
Related: https://salesforce.stackexchange.com/questions/302790/add-a-delay-timer-when-a-batch-class-is-executed-without-scheduler
Thanks