function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PavanReddyPavanReddy 

Which trigger fire first?

I have faced below question  in the couple of interviews..

 

Q)I have written  two triggers T1, and T2 Which trigger fires first?Couls you guys pls elaborate on this?The other scenario is

 

Q) Witten trigger Onaccount object i have written two triggers first one is on contact and second one is on oppurtunity? which will fire frst?

 

Thanks in advance..

sfdcfoxsfdcfox
The first question is indeterminate from the information provided. I cannot presume which of T1 or T2 will fire first without knowing the events that trigger T1 and T2, the objects they trigger on, and what DML operation is being performed. Without knowing what to ask, you won't know how to answer this question. You will need to learn how triggers interact in order to know the answer. The second answer is likewise indeterminate from the information provided. Making zero assumptions about the actual code yields no possible hints that identify one single answer. This is something that would require elaboration or code samples, plus entry conditions.
souvik9086souvik9086

Hi,

 

  • 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.

You can refer this link
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

Yoganand GadekarYoganand Gadekar

If you have two triggers on object then i think it depends on your context before /after if there is no difference in that then they will fire randomly.

 

***** it is always good/recommended to have only one trigger per object.

 

thanks