Building skynet
Triggers that call batch processes are fairly common, but like we mentioned earlier, it's not a good practice to have two sets of code that perform the same function. Sometimes, it's just easier to have your batch process run nightly (or on some other regular basis). This ensures that you start the day fresh with a clean slate and a database full of accurate data. A fairly new method in Apex is now available that lets you schedule the execution of a batch class called System.scheduleBatch()
. The System.scheduleBatch()
method has four input parameters:
Apex class: This is the Apex class that implements the
Database.Batchable
interface.Job name: This is a string you use for easy reference.
Minutes from now: This represents an integer that specifies in how many minutes your batch process should start.
Batch size: This represents the size of each batch processed by the
execute()
method. This parameter is optional and will be set to the default value of200
if not specified.
Calling...