A lightweight trigger handler framework for Salesforce Apex
Clone or download
ChrisAldridge Merge pull request #4 from MarkHMorrison/master
Add tests for full test coverage.
Latest commit 4fed781 Jan 2, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Created tests for code coverage Dec 30, 2018
License.txt Added MIT licence May 27, 2016
README.md Added licence info to readme.md May 27, 2016

README.md

Lightweight-Trigger-Framework

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.

How to implement this trigger pattern

  1. Copy the ITriggerHandler and TriggerDispatcher classes into your org (in that order). Or you can use the Deploy To Salesforce link below.
  2. 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.
  3. 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.
  4. 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.
  5. Call the static TriggerDispatcher.Run method from your trigger. Pass it a new instance of your TriggerHandler class as an argument
  6. Take a tea break. You've earned it.

Deploy To Salesforce

Clicking the below link will install the classes straight into your Salesforce org. Thanks to Andrew Fawcett for the magic tool that does this.
Deploy to Salesforce

Licence

This project is licensed under the terms of the MIT license.