Context Variables of Apex Triggers

Apex Triggers have access to several context variables that provide information about the trigger event and the records involved. These context variables are automatically provided by Salesforce and can be used within the trigger code to perform various operations.

These context variables provide a lot of information about the trigger event and can be used to perform various operations, such as updating related records, sending emails, or performing calculations.

  1. Trigger.new:  This variable returns a list of the new version of sObject records.
  2. Trigger.old: This variable returns a list of the old version of sObject records.
  3. Trigger.newMap: This variable returns a map of ids to the new versions of sObject records.
  4. Trigger.oldMap:  A map of IDs to the old version of the sObject records.