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
Naganjaneya Lakshman TadepalliNaganjaneya Lakshman Tadepalli 

How do you prevent a trigger running multiple times during a single save event?

Shashikant SharmaShashikant Sharma
You could achieve it by wrtiing your code like below:
Class code :

public Class checkRecursive{
    private static boolean run = true;
    public static boolean runOnce(){
     return true;
        return run;

Trigger code :

trigger updateTrigger on anyObject(after update) {

    //write your code here            


You could read details here ; (
Shashikant's answer is also correct, their one more solution for it.

You can compare old value in trigger with the new value to stop the trigger to run again and again.

Like below
trigger AccountTrigger on Account( after insert) {
     for( Account acc: Trigger.newMap) {
            //Compare old value with new from the oldmap 
            if( acc.AccountNumber != oldMap.get(acc.Id).AccountNumber) {
                   //DO SOMETHING
Juan Pablo Rodriguez M 5Juan Pablo Rodriguez M 5
It was so useful @Shashikant Sharma, thanks a lot! 👍🏻