Types of Triggers in Salesforce

 After triggers are used to access field values that are set by the system (such as a record’s Id or LastModifiedDate field), and to have an effect on changes in alternative records, like logging into an audit table or firing asynchronous events with a queue. The records that fire the once trigger are read-only.

Saleforce Triggers may modify alternative records of identical type because the records that originally fired the trigger. As a Salesforce Trigger Example, if a trigger fires after an update of contact A, the trigger may modify contacts B, C, and D. Hence, Triggers in Salesforce will cause alternative records to change, and since these changes will, in turn, fire additional triggers. The Apex runtime engine considers all such operations one unit of work and sets limits on the amount of operations which will perform to stop the infinite recursion. 


Additionally, if you update or delete a record in its before trigger, or delete a record in its after trigger, you may receive a runtime error. This includes each direct and indirect operations. For example, if you update account A, and therefore the before update trigger of account A inserts contact B, and therefore the after insert trigger of contact B queries for account A. Updates it mistreatment the DML update statement or database technique, then you’re indirectly updating account A in its before trigger, and you may receive a runtime error.

Comments

Popular posts from this blog

General Interview Questions and Answers

20 Performance Testing Interview Questions and Answers

Leadership: a Definition