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
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
SK
Raj VakatiRaj Vakati
You need to use Apex to do the conversion to meet this rquirement .. 
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_examples_convertlead.htm
Lead myLead = new Lead(LastName = 'Fry', Company='Fry And Sons');
insert myLead;

Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(myLead.id);

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);

Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());

 
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.