function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion


what is the difference between before insert  trigger and after insert triggers? can we retrive IDs in before insert trigger?

Laxman RaoLaxman Rao

All the code written in the "before update" triggers, executes BEFORE that DML is committed to Salesforce Database.

Code written in after trigger executes AFTER the commit is made.


So whenever you want to change something for the record or to stop the record from being commited, you can go for before triggers


Record ids are not available in before insert, but record id is available in before delete and before update.

Madhan Raja MMadhan Raja M

Triggers can be divided into two types:


  • Before triggers can be used to update or validate record values before they are saved to the database.
  • Aftertriggers can be used to access field values that are set by the database (such as a record'sIdorlastUpdatedfield), and to affect changes in other records, such as logging into an audit table or firing asynchronous events with a queue.

For more details:


Madhan Raja M