function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SBNSBN 

Lead Conversion to the Exisitng Contacts

Hi ,

I have a trigger on a Contact object which converts the Leads( If exists) by matching the Email id to a contact if a new contact is inserted into the Contact Object.

The issue is, some of the Leads in the database doesn't have the email id so the trigger didnt convert lead to contact instead created a new contact. For  future records I can change the code to match by Phone Number or Name but for the exisitng Leads and contacts, What would be the best procedure to convert the exisitng leads to the exisiting contacts by matching the Phone Number/Name.

Thanks
Phillip SouthernPhillip Southern
Once you lay out how you want to match them and find the matches, you can set the contact id on the lead convert instance.  The method is:

leadconvert.setcontactid('ID');

source: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_Database_LeadConvert_instance_methods.htm

Does that help or am I not following the questions?
Ashish_SFDCAshish_SFDC
Hi SBN, 


See the link below - which explains with example how to avoid duplicate leads on conversion:

http://www.salesforce.com/docs/developer/cookbook/Content/apex_dedupe.htm

Also read below, 

http://starrforce.com/2011/01/best-salesforce-practice-of-the-week-have-happy-data-avoid-creating-duplicate-records-from-leads/

There is also a trigger below, 

http://salesforce.stackexchange.com/questions/14604/lead-convert-to-avoid-duplicate-values-to-contact


Regards,
Ashish
SBNSBN
Thanks for the replies...

But as  I said I need to convert the exisiting leads in the lead object  to the exisiting contacts in the contact object  by matching the phone number or name . Please let me know the best procedure for it.

Thanks

Ashish_SFDCAshish_SFDC
Hi SBN, 


While creating a Lead - usually manually done if a contact exists then an opportunity is created but not a Lead - that is a procedural flow. 

If doing from an API etc you can use the Code in the below thread which will validate and then only Insert. 

http://salesforce.stackexchange.com/questions/10151/apex-trigger-update-lead-if-contact-with-same-email-already-exists


Regards,
Ashish
SBNSBN
Hi Ashish,

Thank for the reply. I will try with this and will let you know if this is working or not