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
akkkakkk 

How to perform the Upsert Function with Apex Trigger ?

Hi All,

Please any one support me that How to perform the Upsert Function with Apex Trigger ?

Thanks
akkk
SwethaSwetha (Salesforce Developers) 
HI Akkk,
When you do an upsert DML in trigger code, for records that already exist, it will fire updates. For records that are new, it will fire inserts. As a result, an upsert can cause both insert and update triggers to fire if you have both new and existing records in your upsert, but they both won't fire for the same record.

Please see https://salesforce.stackexchange.com/questions/141140/upsert-from-a-trigger which gives good insight with code snippet
https://salesforce.stackexchange.com/questions/9917/trigger-upsert-questions
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_examples_upsert.htm

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
akkkakkk
Hi Swetha
Thanks for Replying,

but my question is not full filling your answer because want to in Trigger formate 

Thanks