-
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
Group Shared Code
See PlatformEventRecipesTriggerHandler
Constructs a trigger handler object and ensures the context is set
TESTVISIBLE
TESTVISIBLE
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 to allow the trigger to run. |
In the context of a TriggerHandler class,
this.setMaxLoopCount(5);
Allows developers to turn off the max loop count
In the context of a TriggerHandler class,
this.clearMaxLoopCount();
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 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 check whether a given trigger handler class is currently bypassed.
Param | Description |
---|---|
handlerName |
The name of the trigger handler class to check for |
Type | Description |
---|---|
Boolean |
Boolean |
TriggerHandler.isBypassed('AccountTriggerHandler');
removes all classes from the bypass list
Triggerhandler.clearAllBypasses();
TESTVISIBLE
private instancemethods
TESTVISIBLE
Internal method for manually setting the trigger context
Param | Description |
---|---|
ctx |
The current trigger Context |
testMode |
Is the trigger running in a test context? |
TESTVISIBLE
increment the loop count
Exception | Description |
---|---|
Throws |
loop count exception if the max loop count is reached |
TESTVISIBLE
make sure this trigger should continue to run
Type | Description |
---|---|
Boolean |
Boolean |
Exception | Description |
---|---|
TriggerHandlerException |
thrown when executing outside of a trigger |
TESTVISIBLE
Returns the string version of the handler class being invoked
Type | Description |
---|---|
String |
String Name of the Handler |
TESTVISIBLE
SUPPRESSWARNINGS
context methods
TESTVISIBLE
SUPPRESSWARNINGS
Virtual method for the implementing class to override
TESTVISIBLE
SUPPRESSWARNINGS
Virtual method for the implementing class to override
TESTVISIBLE
SUPPRESSWARNINGS
Virtual method for the implementing class to override
TESTVISIBLE
SUPPRESSWARNINGS
Virtual method for the implementing class to override
TESTVISIBLE
SUPPRESSWARNINGS
Virtual method for the implementing class to override
TESTVISIBLE
SUPPRESSWARNINGS
Virtual method for the implementing class to override
TESTVISIBLE
possible trigger contexts
Internal TriggerHandler custom exception class
Inheritance
TriggerHandlerException
TESTVISIBLE
inner classes
Loop counter method with default of 5.
Sets loop count based on the param.
Param | Description |
---|---|
max |
Maximum number of loops to allow. |
Increment the internal counter returning the results of this.exceeded().
Type | Description |
---|---|
Boolean |
Boolean true if count will exceed max count or is less than 0. |
Determines if this we're about to exceed the loop count.
Type | Description |
---|---|
Boolean |
Boolean true if less than 0 or more than max. |
Returns the max loop count.
Type | Description |
---|---|
Integer |
Integer max loop count. |
Returns the current loop count.
Type | Description |
---|---|
Integer |
Integer current loop count. |
Sets the max loop size
Param | Description |
---|---|
max |
The integer to set max to. |