I have Account object which have two Trigger, one trigger has events before insert and after insert second trigger has after insert event.
So which trigger will fire after the record is saved ?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityI have Account object which have two Trigger, one trigger has events before insert and after insert second trigger has after insert event.
So which trigger will fire after the record is saved ?
Both - ideally you should only have one trigger per object. The issue with having multiple triggers, with the same event on the same object, is you cannot guarantee the order that they will execute.
From the Salesforce order of execution documentation: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm
The order of execution isn’t guaranteed when having multiple triggers for the same object due to the same event. For example, if you have two before insert triggers for Case, and a new Case record is inserted that fires the two triggers, the order in which these triggers fire isn’t guaranteed.
Also more information here: Order of execution of trigger and workflow
If I had seen that answer before I probably would have flagged this question as a duplicate...