How to develop Apex Trigger to Prevent Duplicate Contact?

Apex Trigger to Prevent Duplicate Contact Record

Hi Everyone,

In this post, we will discuss how to work with apex trigger and logic building.

Below is the Agenda for the post

1 – Problem Statement
2 – Possible Solution
3 – Choosing the right solution
4 – Solution Approach
5 – Develop the Apex Trigger
6 – Assignment – Develop a Trigger to Prevent duplicate Lead Record based on FirstName, LastName, & Email

Link to Video

Link to PPT

 

Happy Learning 🙂 Sharing is Caring 🙂

#HappyLearning #Salesforce #JourneyToSalesforce

Amit Singh
Amit Singh

Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion

Articles: 299

Newsletter Updates

Enter your email address below and subscribe to our newsletter

6 Comments

  1. Hi Author,

    I wrote a trigger to avoid duplicate contacts, but the problem with it is that it throws an error when I try to update(any other random field) an existing contact record because it compares the email with the same record’s old version and throws an error. I thought your code might solve the issue but it is the same in your case too.
    The above trigger is not suitable for ‘before update’ , I am working on the solution for the same, will post soon.

    Regards,
    Amarnath

  2. Hi Amit,
    how can we create/update other Object records when we have used either addError or any validation rule becoz that will roll back everything even by using async also that will not work.
    Is there any way by which we can raise error on contact and create a task or something like this.

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from Panther Schools

Subscribe now to keep reading and get access to the full archive.

Continue reading