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
Vijay NagarathinamVijay Nagarathinam 

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

Hi,

Currently, I am calling a batch class from the trigger.While running the trigger I am getting below error.


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

If anyone know how to resolve this issue. Please let me know.

Thanks,
Vijay
vijayabakarareddy yarrabothulavijayabakarareddy yarrabothula
In your Trigger code something like below :-

1// BatchClass is the name of batchclass
2BatchClass bh = new BatchClass();
3Database.executeBacth(bh);
My only concern is that the Trigger would fire on the DML events and that would invoke the Batch.Do you want to run batch as many times as the Trigger would fire ??

If this helps,please mark it as best answer to help others :)
Ravi Dutt SharmaRavi Dutt Sharma
Vijay,

Can you post the trigger code so that it is more clear why are you getting this error. Thanks.