-
Notifications
You must be signed in to change notification settings - Fork 458
SampleHandler
ISTEST
This class is a sample trigger handler for use while testing the metadataTriggerHandler. Because custom metadata cannot be inserted, and because the MetadataTriggerHandler instantiates handler classes from custom metadata records, even when we stub/mock the metadata record retrieval we still need an actuall class that it can instantiate.
Note, this class is annotated with @isTest
to prevent it's use outside of
tests, not because it contains tests.
Inheritance
Inherited
TESTVISIBLE
protected context
TriggerContext
public override void beforeInsert()
void
public override void beforeUpdate()
void
public override void afterInsert()
void
public override void afterupdate()
void
public override void beforeDelete()
void
public override void afterDelete()
void
public override void afterUndelete()
void
Inherited
This is main brokering method that is called by the trigger. It's responsible for determining the proper context, and calling the correct method
public virtual void run()
void
AccountTriggerHandler.run();
Inherited
Allows developers to prevent trigger loops, or allow a limited number of them by setting the maximum number of times this trigger is called.
public void setMaxLoopCount(Integer max)
Name | Type | Description |
---|---|---|
max | Integer | A valid number (generally 1) of times you'd like |
to allow the trigger to run. |
void
In the context of a TriggerHandler
class:
this.setMaxLoopCount(5);
Inherited
Allows developers to turn off the max loop count
public void clearMaxLoopCount()
void
In the context of a TriggerHandler
class:
this.clearMaxLoopCount();
Inherited
Allows developers to conditionally bypass (disable) other triggers that also implement this triggerHandler
public static void bypass(String handlerName)
Name | Type | Description |
---|---|---|
handlerName | String | Class name (String) of the trigger handler to bypass |
void
TriggerHandler.bypass('AccountTriggerHandler');
Inherited
Removes a given trigger handler class name from the list of bypassed trigger handlers.
public static void clearBypass(String handlerName)
Name | Type | Description |
---|---|---|
handlerName | String | Handler class name to remove from the bypass list |
void
TriggerHandler.clearBypass('AccountTriggerHandler');
Inherited
Allows developers to check whether a given trigger handler class is currently bypassed.
public static Boolean isBypassed(String handlerName)
Name | Type | Description |
---|---|---|
handlerName | String | The name of the trigger handler class to check for |
Boolean
TriggerHandler.isBypassed('AccountTriggerHandler');
Inherited
removes all classes from the bypass list
public static void clearAllBypasses()
void
Triggerhandler.clearAllBypasses();
Inherited
TESTVISIBLE
increment the loop count
protected void addToLoopCount()
void
Throws: loop count exception if the max loop count is reached
Inherited
TESTVISIBLE
make sure this trigger should continue to run
protected Boolean validateRun()
Boolean
TriggerHandlerException: thrown when executing outside of a,[object Object],trigger