You need to sign in to do that
Don't have an account?
Sanch
Apex question
Hi guys,
I have a bunch of entities, and all of them have trigger's for their own before and after triggers. The top parent entity trigger triger's bunch of other entities trigger because it updates some fields in those entities. Due to this, I run out of the Query limit. The problem is, sometimes, I don't need the trigger to do anything, but the trigger still get trigered. I can't seem to control how to stop the trigger from triggering with in the code. Is this possible? If yes, how can I do this? Thanks.
Sanch.
if(something == true){
Execute the trigger code in here
}
Even with this type of control statement you still need to ask yourself will there ever be a situation in which all the riggers would still get fired. If so you'll still have the same problem. Also, are your triggers setup to process the records in bulk? If not, you will hit the governing limits real quick.
if(Trigger.isDelete){
Do something.
}
Could you provide some more information on the business process and what you are trying to accomplish.
Are any of those triggers related in some sort of way or do they all address unique issues. If they are related perhaps you could consolidate triggers and use 'update' to process the related records rather than a trigger on each object.
Sorry I couldn't be of more help.
Message Edited by TehNrd on 08-20-2007 01:37 PM
I currently use APEX classes in this way to avoid recursion when dealing with triggers that have the potential to create an infinite loop.
I created a flowControl class with a variable and two methods. One that returns the variable and another that sets the variable. Is it possible to set the variable in the class directly without having to use a method?
Class:
Code: Its use in a Trigger:
Code:
Message Edited by TehNrd on 08-22-2007 04:12 PM
Message Edited by TehNrd on 08-23-2007 10:13 AM