A lightweight trigger handler framework for Salesforce Apex.
Complex Apex trigger frameworks getting you down? This is a very lightweight trigger framework to get you started.
Full details and implementation steps can be found on my blog at http://chrisaldridge.com.
- Copy the ITriggerHandler and TriggerDispatcher classes into your org (in that order). Or you can use the Deploy To Salesforce link below.
- Create an objectTriggerHandler class (such as OpportunityTriggerHandler), which implements the ITriggerHandler interface. Have a look at the AccountTriggerHandler class in this repository for a working example.
- Add logic for the methods you require. For example, if you want some BeforeInsert logic, add it to the BeforeInsert method in your handler class.
- Create a trigger for your object which fires on all events. If you're using MavensMate/Sublime Text, there is a template for this when you create a new trigger. Take a look at the example AccountTrigger in this repository if you're not sure.
- Call the static TriggerDispatcher.Run method from your trigger. Pass it a new instance of your TriggerHandler class as an argument
- Take a tea break. You've earned it.
This project is licensed under the terms of the MIT license.