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
MRDJMRDJ 

Trigger to upsert the record if the same record already exists

Can someone share the sample code how to perform the upsert operation with trigger if the record already exists in the object then it should just update (and shouldn't insert to avoid duplicate) and if the record doesn't exist then insert the record. Using external id field on the object, but I do not want to display any error message in the UI saying the record already exists/duplicate. It should simply update the existing one or skip the record.
Pankaj MehraPankaj Mehra
Hi MRDJ,

In trigger at the time of upsert write the name of the external Id after list of object like
 
upsert ListOfOpportunities External_Id__c;

Thanks