Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am getting the below exception when I am running batches in sequence. That is, I am calling another method to create next batch once the first batch is in it's finish method.

Database.executeBatch cannot be called from a batch start, batch execute, or future method.

I am sure we are using latest version of the Batchable interface.

Any help would be appreciated. Thanks in advance!

share|improve this question

3 Answers 3

Most likely problem is the Salesforce API version that the Batchable class is set to. That needs to be >= 27 for the batch chaining from the finish method to work.

share|improve this answer

Hey It works only in API version 27. Change API version to 27. Will work for you. :)

share|improve this answer
    
Interesting. Do you have any proof/link to official docs about that? I have 1 batch starting out of finish() method of another and it works like a charm (API v 23) –  eyescream Aug 11 at 6:11

I have changed the version to 26 and it worked :) It was initially 25 fyi.

share|improve this answer
    
Please don't add "thank you" as an answer. Instead, vote up the answers that you find helpful. –  Bachovski Aug 13 at 6:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.