You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Often we come across scenarios when a bulk update or certain operation(s) are required to be done , while keep the trigger state as inactive.
To incorporate that I would like propose to add a new method : protected virtual boolean isTriggerEnabled() to the class.
The expectation is that this method is to be overridden by implementing object specific triggerHandler classes so that the developers can
put check on configurations (e.g. Custom Metadata / Custom Settings).
Also inside the run method we would require a small change like :
The expectation for the isTriggerEnabled() override is something as below :
public override Boolean isTriggerEnabled() {
Boolean returnedValue = false;
/****************************************************************************
Validate settings from Configuration like Custom metadata / Custom settings
For each custom object there needs to be a separate configuration record
****************************************************************************/
Custom_Trigger_Parameter__c trig = Custom_Trigger_Parameter__c.getInstance();
genesis__Org_Parameters__c orgParam = genesis__Org_Parameters__c.getInstance();
if(trig?.AppTrigger__c == False && orgParam?.genesis__Disable_Triggers__c == False){
returnedValue = true;
}
return returnedValue;
}
The text was updated successfully, but these errors were encountered:
I think Kevin's idea for the framework is for it to be pure Apex, not relying on other metadata to deploy.
Your idea is quite simple to implement without modifying the framework too. All you gotta do is add a check for each trigger event on your handlers and return early if the trigger is disabled.
publicvoidbeforeInsert() {
if (isTriggerEnabled()) {
// halt trigger execution if the custom metadata check failsreturn;
}
// continue execution if trigger is enabled
}
You could either copy your snippet onto your trigger handlers or create a virtual class and make your handlers inherit this (which I think is preferred, to save lines of code and extra work).
Often we come across scenarios when a bulk update or certain operation(s) are required to be done , while keep the trigger state as inactive.
To incorporate that I would like propose to add a new method : protected virtual boolean isTriggerEnabled() to the class.
The expectation is that this method is to be overridden by implementing object specific triggerHandler classes so that the developers can
put check on configurations (e.g. Custom Metadata / Custom Settings).
Also inside the run method we would require a small change like :
The expectation for the isTriggerEnabled() override is something as below :
The text was updated successfully, but these errors were encountered: