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

Lead Assignment Rules : New lead conversion when a contact already exists

Hi everyone,


I am hoping that someone could help me out and I apologize if I posted this in the wrong section. I am new to the developer force. My company has the Enterprise version of SFDC.


I am trying to find a way to have new leads that come in to SFDC convert automatically if there is an existing contact or if the leads company is an existing account. I don't know Apex code all that well so anything would help.


Thank you!



            You can implement this functioanlity in apex code through convertlead operation in database method.

                                    Convertlead operation in database method converts the lead into account,contact and opportunity

                                    Follow the sample code it would help you in achieving your objective.

                                    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);



                                                for more information you can visit apex guide for summer'11 for convert lead operation.


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.




I'm currently trying this snippet in a trigger and when I make a lead, it says that it was converted after I save it. However, when I check my Account and Contacts objects, there are no new records and the lead gets deleted.


Only difference between my code and what is posted is that I am running it through a loop on a trigger on the lead object after insert.


Been scratching my head all day trying to figure out what I'm doing wrong after looking at 4-5 different tutorials that are essentially the same.