Bigger, better, and batchier

The Database.Batchable interface can be a lifesaver when dealing with large datasets. As there is a limit on the number of callouts that can occur in a single transaction, the Batchable interface is often used to sync data with outside systems. In order to perform a callout from an implementation of the Database.Batchable interface, you need to make a small tweak to your class definition. In addition to implementing the Database.Batchable interface, you must also implement the Database.AllowCallouts interface, shown as follows:

//Apex Class that implements the Batchable interface
global class contactBatch implements Database.Batchable<SObject>, Database.AllowCallouts {
  ...
}

Your code to perform callouts can occur in ...

Get Learning Apex Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.