You need to sign in to do that
Don't have an account?
9876543210
Trigger question 1
Two objects are there object1 & object2
if object1 is update then automatically object2 is updating, vice versa object2 is update automatically update object1
these two objects are in loop conditions.
My question is how u will stop the updating.
Explain me how many ways we can stop the updating..
Please reply this question...
Hi,
to do this you have to set a static variable in your trigger. In each trigger you run the update only if the trigger wasn't registered before in the static variable.
Pseudo Code:
class TriggerControl
{
public static Set<String> executedTriggers{
get{
if(executedTriggers == null) executedTriggers = new Set<String>();
return executedTriggers;
} set;}
}
trigger Object1Trigger on Object1__c (<events>)
{
if(TriggerControl.executedTriggers.contains('Object1Trigger'))
{
TriggerControl.executedTriggers.add('Object1Trigger');
update ...;
}
}
When designing triggers, if proper thought is not given, it can easily go out of control. There are established design concepts and patterns to handle both recursive and non-recursive calls on the apex triggers. The following resource might be helpful for you to architect/design/develop your triggers.
Regards,
HK.