+ Start a Discussion
sp13sp13 

how to set which trigger to execute first

what if i have 5 triggers on Object1__c, how can i set which of the five triggers to execute first? is it possible?
Vinita_SFDCVinita_SFDC
Hello,

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.

Reference: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm
Elie.RodrigueElie.Rodrigue
What you can do instead is create a class that contains all of your triggers code. Then have a single calling each methods one by one.
Have a look at this : 
http://www.embracingthecloud.com/2010/07/08/ASimpleTriggerTemplateForSalesforce.aspx
Saravanan @CreationSaravanan @Creation
Hello,

As Vinit said the order of execution if you have multiple Trigger on single object. So the best solution and also the best practice of salesforce 
is for an object there should be only one trigger.

In that based on trigger event you can control the order the exectuing your own methods.

Thanks,