Triggers and Managing Trigger Execution
In this chapter, I want to discuss Apex triggers and correctly managing and developing a structured execution framework for using triggers within Apex.
Triggers are where most developers start working in Apex on the Salesforce Platform, and I would personally estimate that’s where the majority of Apex bugs are found. I think there are a few reasons for this:
- Triggers demand bulkification, and a small resource leak can easily break a governor limit
- Triggers often fire off other save processes that themselves may fail or over-consume resources
- Triggers can be impacted by administrative changes more than other areas of code (validation, processes, flows, and so on)
- As triggers are the first thing many developers touch, they are the most prone to bugs due to inexperience
In this chapter, we will cover the following topics:
- How triggers operate
- The Salesforce save order of execution
- Best practices...