3

Trigger Framework in Salesforce

Learn how to completely and cleanly control your Apex code with Trigger Frameworks, why they’re useful, and the various ways to implement them. In this session will talk about Apex Trigger Framework in Salesforce and benefit of using a trigger framework, How many trigger framework are available, which one is lightweight apex trigger framework and Comparison of different approaches.

In this session we talk about all below Trigger Framework

  • Trigger Handler Pattern
  • Trigger Framework using a Virtual Class
  • Trigger Framework using an Interface
  • An architecture framework to handle triggers

Why Trigger Framework

Triggers are a powerful tool that can do great things when used correctly but cause a lot of headache when used incorrectly. Triggers without structure can be messy. They can interfere with one another and cause huge performance and debugging problems.

  • Generic code that can be extended for any object
  • Ensures triggers are consistently handled and only required code is needed.
  • Allows for simple Triggers and handlers.
  • handles routing for you
  • enforce consistent trigger behavior
  • Easily allows for trigger bypasses
  • Allow you to enforce different behavior for triggers that start a process vs. mid process.

Trigger Handler Pattern

Please check this post to learn about Handler pattern and code. Lets talk about what is the advantage of Trigger Handler Patter.

  1. Apex Class that handles trigger logic
  2. Allows code to be called from other code or tests
  3. Uses specific Trigger contexts and Trigger variables for routing
  4. Keep Triggers Simple
  5. Allow for greater flexibility
  6. Make code reusable
  7. Unit tests are much easier

What is missing in Handler pattern ?

  1. Still duplicated code in every trigger
  2. How can we simplify things?
  3. How can we make our process repeatable?

Trigger Framework using a Virtual Class

Please check this post to learn more about Virtual Class Trigger Framework.

Accomplishments with this Trigger framework :-

  •  1 line trigger
  • Only need to add handler methods that we want to use
  • All routing is handled for us

Trigger Framework using an Interface

Please check this post to learn about this framework.

Accomplishments with this Trigger framework :

  • 1 line trigger
  • All routing is handled for us
  • All handlers are consistent and will have the same methods
  • Multiple ways to deactivate a trigger


An architecture framework to handle triggers

Please check this post to learn about this framework.

Accomplishments with this Trigger framework :-

  • 1 line trigger
  • All routing is handled for us
  • Establish all methods while letting us pick and choose which ones we want
  • Individual event handler methods

Recording

Agenda:

  1. How Triggers Work
  2. Why Trigger Handlers
  3. Why Trigger Frameworks
  4. Create a Trigger Framework using a Virtual Class
  5. Create a Trigger Framework using an Interface
  6. Comparison of different approaches
  7. Drawbacks to Frameworks
  8. Summary and Wrap Up

Speaker : ADAM OLSHANSKY
Date : Saturday, 08 JUNE 2019 10:00 AM EST ( 7:30 PM IST)

Please note that we have limit of 100 attendees that can join the online sessions. However, recording will be posted on our YouTube channel. Make sure to subscribe our YouTube channel to get notification for video upload.

Further Learning

Here is link for all frameworks:-

Comments(3)

  1. Reply
    Rohit says:

    Please send me the notifications of new posts

Post a comment