A pattern of Salesforce trigger helper.
The purpose of this repository is:
- to keep your trigger handler clean;
- to streamline the trigger helper.
In most of the cases, the steps of writing a Salesforce trigger can be described as follows;
- iterate through all the records which fire the trigger, find the cared record subset by certain criteria;
- take some actions to the record subset;
- sometimes take additional actions after the execution of the main actions (in step 2).
By using this pattern, you can define each business logic as a sub-class of a trigger helper. And you can define the three steps as the following method:
- filter()
- execute()
- finish()
In this way, the trigger helper will be clean to read and easier to manage.
This pattern is handler-neutral, which means you can use your favorite trigger handler framework together with this solution.
Copy the TriggerHelper.cls, Triggerable.cls and Finishable.cls under /src/classes to your Salesforce project and follow the ExampleTrigger.trigger for more details.
