I am building a functionality that calls an external APEX API endpoint: whenever a case is updated in Salesforce with certain conditions, send 2 fields to the API endpoing and update the Incident on the application.

The application has a REST callout that specifies the JSON to use in order to update an Incident.

My approach is to work on the After Update trigger, that calls a Handler class, then calls a Future methos in another API Class. This future method will have the callout to update 1 Incident.

My question is: I know that there is a limit of 100 callouts in the same Transaction. SO, what happens if Salesforce updates 1000 Cases at 1 time. I know that 200 will be processed at the same time, but how to handle calling 200 times the API REST method that is used to update the Incident?

Thanks so much.


A design pattern to use is chained queueables

  • The trigger invokes the queueable, passing in the qualifying ids to the queueable's constructor (let's say Q ids; 0 < Q <= 2000)
  • The queueable's execute takes the first n, n < 100 Ids, queries for the record and does n callouts.
  • The queueable starts another queueable of the same class, passing to the constructor a collection of Ids of size Q-n. Obviously, don't start another queueable if the number of Ids to process is less than n

Make n configurable as you also have to worry about total callout time and possibly total transaction time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.