+ Start a Discussion
Shawn Kaiser 7Shawn Kaiser 7 

converting leads to contact and existing account based on domain

I am looking for code for a trigger to:
1. convert a lead to an existing contact and account if already exists based on the domain. Can this code be written with a button that the users can control, by selecting the button it will check for existing domain and if so it will convert the lead.
2. Have a mass conversion take place nightly to do the same as #1
Much appreciated in advance
Raj VakatiRaj Vakati
You need to use Apex to do the conversion to meet this rquirement .. 
Lead myLead = new Lead(LastName = 'Fry', Company='Fry And Sons');
insert myLead;

Database.LeadConvert lc = new database.LeadConvert();

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];

Database.LeadConvertResult lcr = Database.convertLead(lc);

Shawn Kaiser 7Shawn Kaiser 7
Let me clarify... I dont want it to match to company name, I am looking to have it converted if it matches email domain.