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
krish4ukrish4u 

Apex Queueable

Hi Friends,

We have a requirement like, Batch job updates the Opportunity field if the field is changed then we need to send the information to third party system. It might be bulk records.

I am trying to write the future call from Opportunity trigger after update event. but getting the error we can't call the future method from batch job. will it come under the batch job transaction?

So i am planning to write the apex queueable, but the apex queueable also we can call one time in the batch job transaction. if we get more records then how to split the records and send it third party system. 

Please suggest on this.

Thanks,
Krish
 
Alexander TsitsuraAlexander Tsitsura
Hi Krish,

For allow call future methods from batch you need implement Database.AllowsCallouts interface
implements Database.batachable<Sobject>, Database.AllowsCallouts

As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you.

Thanks,
Alex
 
krish4ukrish4u
Hi Alex,

Database.AllowsCallouts will be used to send the information(call out-httprequest) to external system from the batch job itself. we can't call the future methods from the batch job.

Thanks,
Krish
 
Alexander TsitsuraAlexander Tsitsura
Hi Krish,

You can change batch size to 1.
Database.executeBatch(YOUR_BATCH, 1);

Thanks,
Alex