You need to sign in to do that
Don't have an account?
Batch in Batch
Hi,
I've a problem with my Batch-Apex.
I want to send out Information through a callout. But this Information must send after and after. So I create two Batchjobs (because of two diffrent SOQL and parser-functions) and want to start them in a row.
Batch1
- do it´s work
- at finish-functions start Batch2
So I started them and ..... Limit Exception. Cannot start a Batch from a Batch.
How can I solve the problem ? I don´t want to write a while-statment and wait till the first job is done to do the next. It is possible to start the second Batch from the first one ? (I don´t want to schedule, or is this the alternative solution for the problem ?)
thanks
One cannot call a Batch Apex from a finish method of another Batch Apex.
A workaround which may work for you may be by creating a Email Handler class which would parse the the email body sent in the finish method of the first Batch Apex and call the subsequent Batch Apex.
Try this out and let me know if that works. Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
All Answers
One cannot call a Batch Apex from a finish method of another Batch Apex.
A workaround which may work for you may be by creating a Email Handler class which would parse the the email body sent in the finish method of the first Batch Apex and call the subsequent Batch Apex.
Try this out and let me know if that works. Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
another option would be use Apex Scheduler and schedule the next batch job in the first job's finish method to run only once 2-3 after the first one completes.
@geeta: Thats a nice idea, but I can only put 10 Jobs at the queue and I need another job to delete them after they done.
@ Ispita_Navatar: I tried it, and it works fine. BUT the limit for outbound mails is 1000
I post that problem in a diffrent Thread.
We are trying to run batch APEX, even we get batch process id (707A000000CuKkeIAF) but there is no entry in AsyncApexJob table to check batch status,do our further operations
AccountUpdaterBatch LeadUpdater = new AccountUpdaterBatch('select sds__LeadKey__c,id from Lead where IsConverted=false',
IsLeadSelectMat,'Lead','For Lead');
LeadUpdater.masterID = IsLeadSelectMat;
LeadUpdater.FMQuery = 'For Lead';
LeadUpdater.selectedObj = 'lead';
ContactbatchId = Database.executeBatch(