Notes
In Salesforce, triggers are used to execute custom code when specific events occur in the system. There are two types of triggers in Salesforce:
-
Before Triggers: These triggers are executed before the record is saved to the database. Before triggers can be used to modify the data that is being saved or to validate it against certain criteria.
-
After Triggers: These triggers are executed after the record is saved to the database. After triggers can be used to perform additional processing or to update related records.
Both before and after triggers can be further classified based on the events that trigger them:
-
Insert Triggers: These triggers are executed when a new record is created.
-
Update Triggers: These triggers are executed when an existing record is updated.
-
Delete Triggers: These triggers are executed when a record is deleted.
-
Undelete Triggers: These triggers are executed when a record is restored from the Recycle Bin.
Note: There is also a special type of trigger called a "Platform Event Trigger" that is executed when a platform event is published.