-
Notifications
You must be signed in to change notification settings - Fork 470
TriggerHandler
An opinionated trigger handler framework. Originally by Kevin O'Hara github.com/kevinohara80/sfdc-trigger-framework
AccountTriggerHandler, PlatformEventRecipesTriggerHandler
possible trigger contexts
increment the loop count @exception Throws loop count exception if the max loop count is reached
Virtual method for the implementing class to override
Virtual method for the implementing class to override
Virtual method for the implementing class to override
Virtual method for the implementing class to override
Virtual method for the implementing class to override
Virtual method for the implementing class to override
Virtual method for the implementing class to override
Allows developers to conditionally bypass (disable) other triggers that also implement this triggerHandler
Param | Description |
---|---|
handlerName |
Class name (String) of the trigger handler to bypass |
TriggerHandler.bypass('AccountTriggerHandler');
removes all classes from the bypass list
Triggerhandler.clearAllBypasses();
Removes a given trigger handler class name from the list of bypassed trigger handlers.
Param | Description |
---|---|
handlerName |
Handler class name to remove from the bypass list |
TriggerHandler.clearBypass('AccountTriggerHandler');
Allows developers to turn off the max loop count
In the context of a TriggerHandler class,
this.clearMaxLoopCount();
Returns the string version of the handler class being invoked
Allows developers to check whether a given trigger handler class is currently bypassed.
Param | Description |
---|---|
handlerName |
The name of the trigger handler class to check for |
TriggerHandler.isBypassed('AccountTriggerHandler');
This is main brokering method that is called by the trigger. It's responsible for determining the proper context, and calling the correct method
AccountTriggerHandler.run();
Allows developers to prevent trigger loops, or allow a limited number of them by setting the maximum number of times this trigger is called.
Param | Description |
---|---|
max |
A valid number (generally 1) of times you'd like |
In the context of a TriggerHandler class,
this.setMaxLoopCount(5);
Internal method for manually setting the trigger context
Param | Description |
---|---|
ctx |
The current trigger Context |
testMode |
Is the trigger running in a test context? |
internal method to forcibly set the trigger context
make sure this trigger should continue to run
inner class for managing the loop count per handler
Loop counter method with default of 5.
Sets loop count based on the param.
Param | Description |
---|---|
max |
Maximum number of loops to allow. |
Determines if this we're about to exceed the loop count.
Returns the current loop count.
Returns the max loop count.
Increment the internal counter returning the results of this.exceeded().
Sets the max loop size
Param | Description |
---|---|
max |
The integer to set max to. |
Internal TriggerHandler custom exception class