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

What does "Database.executeBatch cannot be called from a batch or future method" really mean?
I am getting this error when trying to call a batch from an after insert after update trigger. The batch works when called from the scheduler. I have no @future methods in my org and a Trigger is not a batch method, so anyone knows what the deal is?
Hi, could it be that you update the same objecttype your trigger is based on within your batchjob? this would then cause the trigger to fire again, but now from within the batch job.
All Answers
Hi, could it be that you update the same objecttype your trigger is based on within your batchjob? this would then cause the trigger to fire again, but now from within the batch job.
That looks to have been the problem. I know the documentation on batches states that you need to be cautious not to get in a loop where the batch causes a trigger to fire which then recalls the batch. That was not my situation. I knew that the batch would fire the same object trigger that originally fired the batch, but I had logic in the trigger that would prevent the batch from being called again. Apparently that is not good enough and if your batch is called from an object's trigger, you cannot re-enter the trigger again while the batch is executing even if you have logic that prevents looping. The Apex documentation is not clear on this and the error message (ie. "cannot be called from a batch or future method") is useless.
Thanks for your suggestion!