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

Updating records for two Objects in both directions

Hi Everyone

I need to relate two standard objects (Lead and Event) for whatever reason. Everytime a record is changed in Lead, it has to change in Event. But in both ways, I mean, from Lead to Event and from Event to Lead.

it is simple by doing it in one way , I have a trigger (working fine) that update a Event record everytime a record is changed in Lead. But, and here comes the question, how do I do the update in both directions?

I thought doing it with another trigger but it would be an infinite loop. Once the trigger on Lead updates the record in Event, the trigger on event would fire and so on...

Anyone can help me?

Thanks in advance for your time
Best Answer chosen by AlbertoSM

if you are thinking about another trigger u can do that but you have to stop recursion of both triggers mean's you need a avoid the recursive call of the trigger.

this way you can achieve your task using trigger do that on both objects 

public Class checkRecursive{
    private static boolean run = true;
    public static boolean runOnce(){
     return true;
        return run;
trigger updateTrigger on anyObject(after update) {

    //write your code here            


if still, you have any problem Let me know that and if this was helpful don't forget to mark as best answer

Thank you  
Avaneesh Singh