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
__sandra____sandra__ 

Problem with Batch making many callouts

Hi,

 

For my organization I have developped some callouts to an external web service once accounts are updated. If an error occured while calling the WS, I update an error field on the account.

 

Now i want to develop a batch that makes callouts for all accounts that has the error field not null.

 

The problem is it seems that i cant do more than one callout in the execute method of a batch..

 

So How can I develop  a batch that for a list of accounts, recalls the WS and updates the error filed again for each account?

 

Thank you!

 

Regards

Best Answer chosen by Admin (Salesforce Developers) 
ClintLeeClintLee

If you're only doing one callout per Account, you can set your batch size to 1 by using Database.executebatch( yourBatchClass, 1 );  The second argument is optional and specifies the number of records to pass to the execute method.

 

~ Clint

All Answers

ClintLeeClintLee

If you're only doing one callout per Account, you can set your batch size to 1 by using Database.executebatch( yourBatchClass, 1 );  The second argument is optional and specifies the number of records to pass to the execute method.

 

~ Clint

This was selected as the best answer
__sandra____sandra__

Thank you Clint for your response

 

But If a have to call a batch for 30 accounts..

 

I cannot do it in one execution.. (1 callout per batch)

 

and I cannot schedule 30 batchs so that each one makes a callout for one account.. (Can not schedule more than 5 jobs at a time)

 

So how can I do it?

 

Thanks!

 

__sandra____sandra__

I see what you wanted to say.

 

I will test using the scope as 1 and I will post the result later.

 

Thanks

__sandra____sandra__

Thank you Clint.

 

It does work!