You need to sign in to do that
Don't have an account?

2 triggers on on sObject - question
Hi.
In my system I have 2 triggers on one Account.
The problem is that I must ensure the one triggers executes first and the seccont just after it.
How can I do it?
Thanks!
Simplest solution will be merging both trigger. Or You can make there events different like before and after.
I just can't do it because I have 2 triggers that have to act
after an event is fired.
Does salesforce makes enviroment give any promise about which
trigger is executed before and which after?
Minci,
You would need to combine your logic of 2 tiggers into one. The logic would be executed in the same sequence in which it is written.
Salesforce.com has documented that trigger sequence cannot be predefined. I can remember where I read this though.
As a best practice create one trigger per object and use comment blocks to separate different logic blocks.
By having all logic in one trigger you may also be able to optimize on your SOQL queries.
Good luck!
Or, create a "dispatch trigger".
Change both of your current Triggers into simple classes with an 'execute' method that takes the same arguments as the trigger. Then write a trigger which invokes the classes in the order you want.
It's a reasonable way of having one Trigger for each object, and yet still be manageable by having your code broken out by function.
Best, Steve.
Tahnk you Guys (or girls)!
I thoyght a bout separating into classes. Of caurse that this solution works.
I just wondered if is there a posibility to schedule manualy triggers.
Thanks!