Monday, August 7, 2017

Trigger framework with hierarchical kill switches

An enhancement on existing matured trigger framework from Hari K.

It is very common scenario to disable trigger logic on certain user (e.g. batch) or profile or for entire org. I have enhanced the trigger framework and source code is available at :

https://github.com/c-shah/trigger-framework

How to use it :

The framework already comes with one of the hiearchical setting called : TriggerFrameworkSettings__c.AllTriggersDisabled - this is false by default. If you need to disable all triggers, you can just check this checkbox. and all triggers will be disabled for a given user/profile/org.

This method can also be extended for individual sObject.
You can add <sObject>TriggerDisabled (e.g. AccountTriggerDisabled) custom setting under TriggerFrameworkSettings__c, and that setting will be dynamically be read for that sObject for a given user/profile/org. The trigger at individual sObject will be enabled/disabled based on flag value.

No comments: