My goal is to write an apex trigger that will delete duplicate Opportunity Records based on the Opportunity Name but retain the first record that is created. I believe a before trigger would be the best option.

For example, if the name of the first Opportunity is "Opportunity Alpha" and another user creates an Opportunity called "Opportunity Alpha", I would like the second record to be deleted automatically. Help would be greatly appreciated!


As David mentioned, Salesforce already offers standard functionality for managing duplicates. Creating an Apex trigger would not be necessary in a situation like this. Below is a link to documentation on duplicate management in Salesforce.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.