Metillium Trigger Framework

Recently, I reviewed the Apex Trigger Action Framework and liked it overall but thought it was too granular. This made me want to create a similar trigger framework so I did. Let me introduce you to the “Metillium Trigger Framework”. For complete details, see the Metillium Trigger Framework on GitHub.

Primary Features

  • More granularity and control over my¬†Simple Trigger Framework.
  • Decoupled Trigger Actions.
  • Easy Distribution Through Unlocked Package.
  • No recursion control / prevention since I believe that is better controlled by each trigger action so that allows the framework to be simpler.


High-Level Steps

  1. Install the unlocked package
  2. Create Trigger Action Class
  3. Create Trigger
  4. Create Custom Metadata Records

I’m skipping most of the usage details because the Metillium Trigger Framework on GitHub contains them.

Trigger Action Class Example

global with sharing class AccountCustomValidation extends mtf.TriggerAction {
    public override void beforeInsert(List<SObject> newRecords) {
        List<Account> newAccounts = (List<Account>) newRecords;

        for (Account newAccount : newAccounts) {
            // Add newAccount custom validation here

Trigger Example

trigger AccountTrigger on Account (before insert, before update, after insert, after update, before delete, after delete, after undelete) {
    new mtf.TriggerHandler().run();