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
maximummaximum 

Updating child record fires After Update trigger on master

Should updating a child record fire an update trigger on the master? We have a trigger on Master-Detail record which pushed some values down to the child records. And we have another trigger on the child record which does some computation. Updating master records causes infinite recursion as the master trigger updates child records which fires the master trigger again and on it goes. I also tested updating child record directly and it also seems to fire the After Update trigger on the master.

Has anybody run into this issue before? Is there a solution to this problem?
kpetersonkpeterson
At the very beginning of your trigger you can have some conditional logic that compares old values to new values that says "if one of these fields have been changed then proceed".  Using some conditional logic like this should break your infinite update.  It's also good to do this to make sure your triggers aren't doing unnecessary work all the time.  It can help you stay under limits easier.

Did this help?

maximummaximum
Yes, thank you for suggesting a way to break out of the infinite loop. I don't know why I didn't think of that. I guess I was just too preoccupied by my discovery that child record update also updates the master (and fires triggers). And if that's the correct behavior.