Це відео не доступне.
Перепрошуємо.
Duplicate Contact Trigger || Trigger Logic Building ||
Вставка
- Опубліковано 16 жов 2019
- Want to learn more about salesforce join me at sfdcpanther.com Hi Everyone,
In this video, we will discuss how to work with apex trigger and logic building.
Below is the Agenda for the video
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 ApexTrigger:- gist.github.co...
Link to PPT:- www.slideshare...
Contact Me -
LinkedIn
/ simplyamit
FaceBook
/ sfdcpanther
Twitter
/ cloudyamit
Instagram
t.me/sfdcpanther
Blog
sfdcpanther.com
Email
sfdcpanther@gmail.com
Previous Video
OAuth 2.0 • An Overview to OAuth 2...
#SalesforceForBeginner #Salesforce #ApexTrigger
#JourneyToSalesforce
I have gone through many videos and sites but This is best solution to avoid duplicate records .
Thank You so much :)
This is the best solution i have seen so far for duplicate trigger scenario!
Thank You
NICE ONE Amit Bhai
Hi Amit, the above code is not working for before update scenario. please try to update any field of the existing contact. then it hits duplicate email found. The email of the contact record is getting assigned to both "newEmailSet" and "existingEmailSet".
Very good explanation amit
Awesome😋
Good explanation 🤗
Hi Amit,
Thanks for sharing your knowledge.
I wanted some help from your side regarding interview.
Please tell me scenarios for trigger so that I can do the practice.
Also please tell me how can I do the preparation for my interview.
good explanation
Thank you
Can we use this trigger in lightning component
I need give five possible triggers on this scenario
I need your all videos on the salesforce from beggining so please provide me links
Here is the link for you
ua-cam.com/users/SFDCPanther
trigger is not working for bulk records, when i tried to insert 10 records in that 1 record is duplicate, it should insert remaining 9 records but it is not happening can you help me on ths
Trigger never insert the partial data. It will either fail or pass not other outcomes are there.
If you want to insert the remaining records then first you have to insert all the records and then delete the duplicate records which is not recommended.
If you try to update any field on same record again it will throw error
Hi Amit,
While inserting duplicate records from Anonymous, on line no. 42, we are adding the first contact record email to the set and not calling addError on that record, but for second record, line no. 40 gets executed and we call addError method because we added that email while iterating the first record.
Then, if we are not calling addError for the first record, then at least the first record should be inserted right, because for the second we called addError, and not the first.
Please help me over this doubt.
This may be due to bulkification befaire we are using List to insert records at once. So eaither all will be inserted or none. Since 1 record fails whole list is stopped from inserting.
But how to update other fields of record it fires duplicate error
Yeah. It will show duplicate error. There are 2 options that we can go to resolve the error.
1 - In the trigger check if email field is changed then only execute the rest piece of code.
2 - Do the data clean-up for that object that will resolve the issue as you will not be having the duplicate records for the object.
@@sfdcpanther sir please tell the code to do that
Hai Amit Jii,
I have a doubt, from all new version of records(being to insert, update and undelete)...we are adding email field into set (newEmailSet)...here itself we are filter the duplicate emails then why did we get error when we trying to add contacts with same email. I am not getting your point in your explanation, can you please clarify my doubt.
Adding the emails in a set does not meant that you can prevent the duplicate records.
Set contains unique values that means in a set no duplicate values will be added.
Duplicate record is a complete different things
why we didnt work with newEmailSet
NewEmailSet is only used to get the existing contact emails and once we got the existing email we don't need to use new emails
sir agar aap list me duplicate record dolte ho to kam se kam 1 record to insert ho .. ye to puri list per error aa gaya
Please insert record with anonymous window
If you have duplicate records in a list and trying to update then you will get the error.
What error are you getting?