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
KS KumarKS Kumar 

Triggers question

When the  same operation can be done with
before Insert Trigger or after Insert Trigger which you
prefer and why
KaranrajKaranraj
Its depend upon what action you are trying to perform. Example If you are trying the update the values of the record which you inserted then go for the before insert operation becuase record is not saved in database so you can set your value without making any DML statements in your code. Check this Apex Trigger module in Trailhead to understand more about Trigger logic - https://developer.salesforce.com/trailhead/module/apex_triggers
KS KumarKS Kumar
Thank you
Pavan BPavan B
In before insert operation we dont have the Id of the record ,where that is possible in After insert operation