+ Start a Discussion

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 
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

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