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
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
I know what is the issue and how to resolve that. The aim of the post is to make learn how to develop the code.
Hi Amit,we can use count()-aggregate function which will reduce line of codes here
You can try
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.
That is not possible. As soon as we raise the error the whole transaction will be rolled-back.