You need to sign in to do that
Don't have an account?
nagamalli tadikonda
regarding triggers doubt
what is difference before and after triggers ? when we write after and before triggers ?
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Hi Nagamalli,
BEFORE triggers should be used in below scenarios
AFTER triggers should be used in below scenarios
- If we need to use Record's ID
- Inserting or Updating the related records
- To send notification email post commit
For more information refer below links .http://www.sfdc99.com/2014/01/25/use-vs-triggers/
https://hisrinu.wordpress.com/2011/05/17/difference-between-before-trigger-and-after-trigger/
All Answers
Please go through below blog for requierd information:
https://hisrinu.wordpress.com/2011/05/17/difference-between-before-trigger-and-after-trigger/
Thanks
When you save a record (insert / update) Salesforce fires a DML statement to its database, internally.
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.
Hence if you are trying to update any value in the record, on which the trigger is fired, you need not write an update call, specifically. But you need to do it in after triggers.
example, if a before trigger is written on Account and you want to change a value of one of the fields it would be
but if you will write this on after update you can't update the same field because data is already committed to database so value will be read only.
After update trigger generally works when you want to update any other object. for example if you want to create a new task on account insertion or update you can write logic for that.
The specific use case of an after trigger is when you need to associate any record to a record being created in your trigger. Here’s an example:
Let me know if you have any issues.
Close this thread by marking it as best answer if it cleared your doubts.
Regards
Hi Nagamalli,
BEFORE triggers should be used in below scenarios
AFTER triggers should be used in below scenarios
- If we need to use Record's ID
- Inserting or Updating the related records
- To send notification email post commit
For more information refer below links .http://www.sfdc99.com/2014/01/25/use-vs-triggers/
https://hisrinu.wordpress.com/2011/05/17/difference-between-before-trigger-and-after-trigger/