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
Andrew marshal 3Andrew marshal 3 

How Many Times Trigger Execute On An Upsert Event ?

How Many Times Trigger Execute On An Upsert Event ?
SubratSubrat (Salesforce Developers) 
Hello Andrew ,


Upsert trigger fires on 4 different events :- before(insert, update), after (insert, update)

Reference -> https://www.apexhours.com/salesforce-interview-questions-on-triggers/#4-what-are-different-events-available-in-triggers


Hope the above information is helpful .
Thank you.
Anand kurubaAnand kuruba
Hello Andrew ,
  • In general, an upsert operation (a combination of update and insert) can trigger a trigger to execute once or twice, depending on whether the record being updated already exists in the database or not.
  • If the record being updated already exists, the trigger would typically execute once, as it would for a traditional update operation.
  • If the record being updated does not already exist, the trigger may execute twice - once for the insert portion of the upsert operation and once for the subsequent update operation.
  • It's important to note that the behavior of triggers can vary widely between database systems and trigger implementations, so it's always a good idea to consult the documentation or seek advice from an expert in your specific database system.

Hope the above information is helpful .
Thank you.
please mark best answer.
Arun Kumar 1141Arun Kumar 1141

Hello Andrew,

The insert and update operations are combined in an upsert operation. It depends on the amount of times the trigger will be used.Whether the record being changed already exists in the database will determine if it can be updated.

 Please mark it as best answer, if it helps

Thanks