You need to sign in to do that
Don't have an account?
Ram Arza
Calling multiple classes from a single trigger
I have 2 triggers calling 2 different handler classes on the same object . As part of best practise I want to call both the classes from a single trigger. I am not sure how to call them. Below are my two triggers.
trigger ShippingAddress on Shipping_Address__c (after delete, after insert, after undelete, after update, before delete, before insert, before update ) { try { ITriggerHandler handler = new SingleTriggerHandler ( new ShippingAddressTriggerHandler(), Trigger.isExecuting, Trigger.isInsert, Trigger.isUpdate, Trigger.isDelete, Trigger.isBefore, Trigger.isAfter, Trigger.isUndelete, Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap, Trigger.size ); handler.process(); } catch (AbstractTriggerHandler.InvalidTriggerInvocationException itie) { SystemExceptionLogger.insertSystemExceptionLogEntry( itie, 'Shipping Address Application - Common Use', 'Shipping Address Trigger', SystemExceptionLogger.EXCEPTION_LEVEL_INFO); } catch (Exception e) { SystemExceptionLogger.insertSystemExceptionLogEntry( e, 'Shipping Address Trigger Application - Common Use', 'Shipping Address Trigger', SystemExceptionLogger.EXCEPTION_LEVEL_CRITICAL); throw e; } }Trigger 2
trigger StagingShippingAddress on Shipping_Address__c (after delete, after insert, after undelete, after update, before delete, before insert, before update ) { try { ITriggerHandler handler = new SingleTriggerHandler ( new StagingShippingTriggerHandler(), Trigger.isExecuting, Trigger.isInsert, Trigger.isUpdate, Trigger.isDelete, Trigger.isBefore, Trigger.isAfter, Trigger.isUndelete, Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap, Trigger.size ); handler.process(); } catch (AbstractTriggerHandler.InvalidTriggerInvocationException itie) { SystemExceptionLogger.insertSystemExceptionLogEntry(itie,'Shipping Address Application - Common Use','Shipping Address Trigger',SystemExceptionLogger.EXCEPTION_LEVEL_INFO); } catch (Exception e) { SystemExceptionLogger.insertSystemExceptionLogEntry(e,'Shipping Address Trigger Application - Common Use','Shipping Address Trigger',SystemExceptionLogger.EXCEPTION_LEVEL_CRITICAL); throw e; } }
Delete the second trigger and you can write this ,
You can also swap the order of two handler classes according to your requirement.
Thanks,
Prosenjit
All Answers
Delete the second trigger and you can write this ,
You can also swap the order of two handler classes according to your requirement.
Thanks,
Prosenjit