Coder Social home page Coder Social logo

simple-trigger-pattern's Introduction

##Introduction

This is the official public repository of the Simple Trigger Pattern for Salesforce (STP). This pattern was developed by Salesforce MVP Vivek M. Chawla (@VivekMChawla), a Salesforce Certified Platform Developer (Levels I and II), App Builder, and Advanced Administrator.

The Simple Trigger Pattern can be used to quick-start development of new triggers. It encapsulates several best-practices, including "One Trigger per Object", "No Business Logic in Triggers", and "Recursion Prevention Using Static Variables". The STP also facilitates adoption of the architectural best practice of Separation of Concerns.

NOTE: If you are looking for the Gist "snippet collection" of Simple Trigger Pattern files, you can find it here: bit.ly/SimpleTriggerPatternGist

##Contents

The following files are contained in this repository:

  • LICENSE.txt
    • Copyright and license information
    • All code and documentation are distributed under MIT License
    • If you find this pattern useful, let me know @VivekMChawla
  • README.md
    • The file you're reading right now
  • TriggerHandler.cls
    • Apex virtual class
    • Core component of the Simple Trigger Pattern
    • Must be deployed to your org before implementing STP
    • Does not require customization before deployment
    • All trigger handlers implementing STP must extend this class
  • TriggerHandlerTest.cls
    • Apex test class
    • Must be deployed to your org before implementing STP
    • Does not require customization before deployment
    • Provides 97% code coverage of the TriggerHandler virtual class
  • SampleObjectTrigger.cls
    • Apex trigger template
    • Requires customization before deploying to your org
  • SampleObjectTriggerHandler.cls
    • Apex class template
    • Requires customization before deploying to your org
  • SampleObjectTriggerHandlerTest.cls
    • Apex test class template
    • Requires customization before deploying to your org

simple-trigger-pattern's People

Contributors

vivekmchawla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

simple-trigger-pattern's Issues

Does pattern support Bulk DML retries when allOrNothing=false?

I think this is true after inspecting your trigger pattern. Looking for verification and suggesting you add to your documentation.

If doing a bulk DML operation such as Database.insert(sobjList,false), per the Apex documentation, if some records fail, Apex will attempt a second and possibly third retry on the failing sobjects.

You would not want the trigger recursion static variables to be remembered for the second or third retry as otherwise the retry logic will not execute one's trigger handler business logic.

I believe your pattern addresses this because on a retry, per the doc, the trigger refires which means the xxxObjectTriggerHandler will be reinstantiated for the retry set and thus reset the isXXXXFirstRun booleans.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.