Skip to content

MarkHMorrison/Lightweight-Trigger-Framework

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

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.

About

A lightweight trigger handler framework for Salesforce Apex

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Apex 100.0%