Description | This class provides simple trigger handler management with - a consistent and efficient pattern for trigger handler implementation.
- a central dispatch mechanism
- the ability to disable all trigger handlers that extend this base class
- the ability to disable a single trigger handler
- the ability to disable a single feature within a trigger handler
- optional, automatic CRUD checks
Usage:
// To implement a trigger handler, create a global class that extends this one
global with sharing class AccountHandler extends aBoost.TriggerHandler {
// override TriggerHandler methods needed for your logic...
global override void onBeforeInsert(SObject[] records) {
super.onBeforeInsert(records);
validateFields();
}
global override void onBeforeDelete(SObject[] records) {
super.onBeforeDelete(records);
preventDeletionInSomeCases();
}
}
// Invoke your handler from the trigger by calling run(). The base class then
// works its magic, skipping your handler according to custom settings, or
// calling your overridden method corresponding to the trigger event.
trigger AccountTrigger on Account(before insert, before update, before delete,
after insert, after update, after delete, after undelete) {
new AccountHandler().run();
}
Disabling Triggers To disable all handlers, set the Enable Triggers Apex BOOST custom setting to false. Note that this can be done for an individual user or profile. To disable a single handler, create a Boolean Apex BOOST custom setting with the same name as your handler class. This new setting can now be set to false to disable the handler globally or for a single user or profile. |
---|