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
surasura 

Batch Apex fails due to future calls

My problem is as below
-------------------------------------
  • I want to update existing large number of records So I created a batch apex class to do that task (date loading is not an option becuase field values populated through a complex calculation)
  • but relevant object has a trigger calling future method my batch job fails
  • I cant deactivate or Edit the trigger because it is in manage package so  I cant edit or deactivate or even see it's code.
  • Is there any possible way to run my batch apex without failing (only option I can see is deactivate the trigger but even it is not possible since they are in a mange package)
Shashikant SharmaShashikant Sharma
There is no option for you here, only thing I could suggest is to make your batch size 1 so if there are records which do not meet critria for future job will be processed by batch.

Ideally you should report this issue to Manage Package Vendor as it is not best practice to call a future method without having a check for the context that it should not be from a Batch or a Future

They should always put a check like

// if not a batch or future context them onlu call future method
If( ! ( System.isBatch() || System.isFuture() )) {
// call future method from here
}