{"id":20597815,"url":"https://github.com/kevinohara80/sfdc-trigger-framework","last_synced_at":"2026-02-15T10:11:37.598Z","repository":{"id":8588160,"uuid":"10221821","full_name":"kevinohara80/sfdc-trigger-framework","owner":"kevinohara80","description":"A minimal trigger framework for your Salesforce Apex Triggers","archived":false,"fork":false,"pushed_at":"2024-03-27T20:07:00.000Z","size":45,"stargazers_count":1015,"open_issues_count":23,"forks_count":544,"subscribers_count":102,"default_branch":"master","last_synced_at":"2025-10-30T05:23:00.844Z","etag":null,"topics":["apex","apex-triggers","salesforce","salesforce-api","salesforce-developers"],"latest_commit_sha":null,"homepage":"","language":"Apex","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevinohara80.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-05-22T14:30:02.000Z","updated_at":"2025-10-26T13:58:42.000Z","dependencies_parsed_at":"2025-01-17T01:10:34.186Z","dependency_job_id":"c9ce7e5a-669c-4f69-ac53-41de7e3b1f35","html_url":"https://github.com/kevinohara80/sfdc-trigger-framework","commit_stats":{"total_commits":64,"total_committers":7,"mean_commits":9.142857142857142,"dds":0.125,"last_synced_commit":"b7e36c76a3608674979e44fe3a823b55016fff7c"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/kevinohara80/sfdc-trigger-framework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinohara80%2Fsfdc-trigger-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinohara80%2Fsfdc-trigger-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinohara80%2Fsfdc-trigger-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinohara80%2Fsfdc-trigger-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevinohara80","download_url":"https://codeload.github.com/kevinohara80/sfdc-trigger-framework/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinohara80%2Fsfdc-trigger-framework/sbom","scorecard":{"id":557238,"data":{"date":"2025-08-11","repo":{"name":"github.com/kevinohara80/sfdc-trigger-framework","commit":"b7e36c76a3608674979e44fe3a823b55016fff7c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":2,"reason":"Found 5/24 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 11 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T12:41:47.616Z","repository_id":8588160,"created_at":"2025-08-20T12:41:47.616Z","updated_at":"2025-08-20T12:41:47.616Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29475342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T06:58:05.414Z","status":"ssl_error","status_checked_at":"2026-02-15T06:58:05.085Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apex","apex-triggers","salesforce","salesforce-api","salesforce-developers"],"created_at":"2024-11-16T08:24:03.644Z","updated_at":"2026-02-15T10:11:37.572Z","avatar_url":"https://github.com/kevinohara80.png","language":"Apex","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SFDC trigger framework\n\n[![npm version](https://badge.fury.io/js/sfdc-trigger-framework.svg)](https://badge.fury.io/js/sfdc-trigger-framework)\n[![Maintainability](https://api.codeclimate.com/v1/badges/eeeae5a492e34feace99/maintainability)](https://codeclimate.com/github/kevinohara80/sfdc-trigger-framework/maintainability)\n\nI know, I know...another trigger framework. Bear with me. ;)\n\n## Overview\n\nTriggers should (IMO) be logicless. Putting logic into your triggers creates un-testable, difficult-to-maintain code. It's widely accepted that a best-practice is to move trigger logic into a handler class.\n\nThis trigger framework bundles a single **TriggerHandler** base class that you can inherit from in all of your trigger handlers. The base class includes context-specific methods that are automatically called when a trigger is executed.\n\nThe base class also provides a secondary role as a supervisor for Trigger execution. It acts like a watchdog, monitoring trigger activity and providing an api for controlling certain aspects of execution and control flow.\n\nBut the most important part of this framework is that it's minimal and simple to use. \n\n**Deploy to SFDX Scratch Org:**\n[![Deploy](https://deploy-to-sfdx.com/dist/assets/images/DeployToSFDX.svg)](https://deploy-to-sfdx.com)\n\n**Deploy to Salesforce Org:**\n[![Deploy](https://raw.githubusercontent.com/afawcett/githubsfdeploy/master/deploy.png)](https://githubsfdeploy.herokuapp.com/?owner=kevinohara80\u0026repo=sfdc-trigger-framework\u0026ref=master)\n\n## Usage\n\nTo create a trigger handler, you simply need to create a class that inherits from **TriggerHandler.cls**. Here is an example for creating an Opportunity trigger handler.\n\n```java\npublic class OpportunityTriggerHandler extends TriggerHandler {\n```\n\nIn your trigger handler, to add logic to any of the trigger contexts, you only need to override them in your trigger handler. Here is how we would add logic to a `beforeUpdate` trigger.\n\n```java\npublic class OpportunityTriggerHandler extends TriggerHandler {\n  \n  public override void beforeUpdate() {\n    for(Opportunity o : (List\u003cOpportunity\u003e) Trigger.new) {\n      // do something\n    }\n  }\n\n  // add overrides for other contexts\n\n}\n```\n\n**Note:** When referencing the Trigger statics within a class, SObjects are returned versus SObject subclasses like Opportunity, Account, etc. This means that you must cast when you reference them in your trigger handler. You could do this in your constructor if you wanted. \n\n```java\npublic class OpportunityTriggerHandler extends TriggerHandler {\n\n  private Map\u003cId, Opportunity\u003e newOppMap;\n\n  public OpportunityTriggerHandler() {\n    this.newOppMap = (Map\u003cId, Opportunity\u003e) Trigger.newMap;\n  }\n  \n  public override void afterUpdate() {\n    //\n  }\n\n}\n```\n\nTo use the trigger handler, you only need to construct an instance of your trigger handler within the trigger handler itself and call the `run()` method. Here is an example of the Opportunity trigger.\n\n```java\ntrigger OpportunityTrigger on Opportunity (before insert, before update) {\n  new OpportunityTriggerHandler().run();\n}\n```\n\n## Cool Stuff\n\n### Max Loop Count\n\nTo prevent recursion, you can set a max loop count for Trigger Handler. If this max is exceeded, and exception will be thrown. A great use case is when you want to ensure that your trigger runs once and only once within a single execution. Example:\n\n```java\npublic class OpportunityTriggerHandler extends TriggerHandler {\n\n  public OpportunityTriggerHandler() {\n    this.setMaxLoopCount(1);\n  }\n  \n  public override void afterUpdate() {\n    List\u003cOpportunity\u003e opps = [SELECT Id FROM Opportunity WHERE Id IN :Trigger.newMap.keySet()];\n    update opps; // this will throw after this update\n  }\n\n}\n```\n\n### Bypass API\n\nWhat if you want to tell other trigger handlers to halt execution? That's easy with the bypass api:\n\n```java\npublic class OpportunityTriggerHandler extends TriggerHandler {\n  \n  public override void afterUpdate() {\n    List\u003cOpportunity\u003e opps = [SELECT Id, AccountId FROM Opportunity WHERE Id IN :Trigger.newMap.keySet()];\n    \n    Account acc = [SELECT Id, Name FROM Account WHERE Id = :opps.get(0).AccountId];\n\n    TriggerHandler.bypass('AccountTriggerHandler');\n\n    acc.Name = 'No Trigger';\n    update acc; // won't invoke the AccountTriggerHandler\n\n    TriggerHandler.clearBypass('AccountTriggerHandler');\n\n    acc.Name = 'With Trigger';\n    update acc; // will invoke the AccountTriggerHandler\n\n  }\n\n}\n```\n\nIf you need to check if a handler is bypassed, use the `isBypassed` method:\n\n```java\nif (TriggerHandler.isBypassed('AccountTriggerHandler')) {\n  // ... do something if the Account trigger handler is bypassed!\n}\n```\n\nIf you want to clear all bypasses for the transaction, simple use the `clearAllBypasses` method, as in:\n\n```java\n// ... done with bypasses!\n\nTriggerHandler.clearAllBypasses();\n\n// ... now handlers won't be ignored!\n```\n\n## Overridable Methods\n\nHere are all of the methods that you can override. All of the context possibilities are supported.\n\n* `beforeInsert()`\n* `beforeUpdate()`\n* `beforeDelete()`\n* `afterInsert()`\n* `afterUpdate()`\n* `afterDelete()`\n* `afterUndelete()`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinohara80%2Fsfdc-trigger-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevinohara80%2Fsfdc-trigger-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinohara80%2Fsfdc-trigger-framework/lists"}