function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
cvm_asishcvm_asish 

Need a help in checking the status of each batch apex!

hello friends,

 

I need a help in checking the status of each batch apex!

 

Scenario:

 

01. I have a "for" loop, which will get a list of records(each records contains query).

02. Loop through each record and execute the batchapex.

 

Issue:

 

Consider there are 15 different queries. I think only 5 batch apex can execute at a time (status = Processing or Queued). So in the "for" loop I want to execute the next batch apex only if the previous one is completed.

 

Question:- How we can achieve the above scenario?

 

Current Soln:- I tried with a "While" loop. Inside the "for" loop once the batchapex is executed I'll call a While loop to check the status of that "batch" with the batchID. This While loop will go until I'll get the status "Completed". But the problem here is, if the batch takes more time then the number of SOQL call to check the status in While loop will exceed the "limit".

 

Please help me out!

 

Thanks in advance!

 

Thanks

Asish

Best Answer chosen by Admin (Salesforce Developers) 
Anand@SAASAnand@SAAS

You could chain your batch programs by using a custom object and a time base workflow or apex email and apex email services to kick off another batch.

  

All Answers

Anand@SAASAnand@SAAS

You could chain your batch programs by using a custom object and a time base workflow or apex email and apex email services to kick off another batch.

  

This was selected as the best answer
cvm_asishcvm_asish

hey Anand, thanks  a lot for your idea. I tried that and it did work for me.

 

 

Thanks

Asish

 

Message Edited by cvm_asish on 03-03-2010 02:22 AM