You need to sign in to do that
Don't have an account?
SV 9
Merge 2 duplicate contacts
Could someone please help me with the after update trigger on contact.
Search contacts when email is updated, if there are more than 2 records, exit the loop, displaying an error message. If there are only 2 potential duplicates which have the same email id, then need to merge those 2 records.
Search contacts when email is updated, if there are more than 2 records, exit the loop, displaying an error message. If there are only 2 potential duplicates which have the same email id, then need to merge those 2 records.
You can use a logic similar to mentioned below in your trigger code for after update context:
Please note above code may not work as per exact requirement and you can modify the same as per your requirement.
Refer for more examples:
https://salesforce.stackexchange.com/questions/293825/create-a-trigger-to-merge-leads-if-the-email-already-exists-on-a-lead
https://developer.salesforce.com/forums/?id=906F00000008xmaIAA
Hope above information helps, Please mark as Best Answer so that it can help others in the future.
Thanks.
Try Below Trigger Please Mark It As Best Answer If It Helps
Thank You!
Kindly find your solution. If You find any issue, Kindly reach out to me and
If you find your Solution then mark it as the best answer.
Thanks and Regards
Suraj Tripathi.
Should be able to get both the records to merge, should this be in the forloop?
Contact o = [SELECT ID, Email FROM Contact WHERE Email =: emailset];
Contact cons = [SELECT Id,Email FROM Contact WHERE Email In : emailset;
merge o cons;
Yes i Thnk It Has To Be In For Loop
Please Mark It As Best Answer If It Helps
Thank You!