When to use before and after trigger in Salesforce?

When to use before and after trigger in Salesforce?

Before Trigger:

  1. In case of validation check in the same object.
  2. Update the same object.

After Trigger: 

  1. Insert/Update related object, not the same object.
  2. Notification email.

If we want to update a record of an object, we cannot use After trigger, because it causes read only error. This is because, after inserting or updating, we cannot update a record. Update should be made in before event for the same object.

Leave a Reply