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
ChinnoduChinnodu 

how we can perform upsert operation using trigger ?

Hi All,

i need update the records an contact object, if record is not there then only we need to insert the records using trigger .kindly help me on this .please give me example with functionality.

Thanks in advance 
 
GauravGargGauravGarg
Hi Chinnodu,

To upsert a record you need External_Id or key based on which you identify the record is existing to need to create a new record. To achieve the same with Apex code you need to provide the field API name for the same. 

Go through the link (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_examples_upsert.htm)provided the exact solution. For short use like this: upsert assets Line_Item_ID__c


Thanks,
Gaurav Garg
skype: gaurav62990
email: gauravgarg.nmims@gmail.com