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

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



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{
            if(executedTriggers == null) executedTriggers = new Set<String>();
            return executedTriggers;
    } set;}

trigger Object1Trigger on Object1__c (<events>)
        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.