You need to sign in to do that
Don't have an account?

Trigger to create contacts through lead conversion
Hi,
I have created some custom fields on lead object to capture alternate contact details apart from main contact.
First_Other_Contact_Name__c
First_Other_Contact_Phone__c
First_Other_Contact_Email__c
Second_Other_Contact_Name__c
Second_Other_Contact_Phone__c
Second_Other_Contact_Email__c
My requirement is when we normally convert lead so it become Account, opportunity and contact. I want those custom contacts details should become as second and third contact details under the account.
How can I achieve this. Please help!
Please find below code which is not working as expected:
I have created some custom fields on lead object to capture alternate contact details apart from main contact.
First_Other_Contact_Name__c
First_Other_Contact_Phone__c
First_Other_Contact_Email__c
Second_Other_Contact_Name__c
Second_Other_Contact_Phone__c
Second_Other_Contact_Email__c
My requirement is when we normally convert lead so it become Account, opportunity and contact. I want those custom contacts details should become as second and third contact details under the account.
How can I achieve this. Please help!
Please find below code which is not working as expected:
trigger LeadConvert on Lead (after update) { map<Id, Lead> mapNewLead = trigger.newMap; List<Contact> lstContact = new List<Contact>(); for(Lead objLead: mapNewLead.values()) { if (objLead.isConverted == true) { lstContact.add(new contact(LastName = objLead.First_Other_Contact_Name__c)); lstContact.add(new contact(Phone = objLead.First_Other_Contact_Phone__c)); lstContact.add(new contact(Email = objLead.First_Other_Contact_Email__c)); } } insert lstContact; }
This code is working absolulty fine for me.
All Answers
If you want these contacts to be associated with the account, you'll need to set the accountId field, otherwise they will be private contacts to the user that carried out the conversion. You can find the account id in the 'ConvertedAccountId' field in the lead record.
This code is working absolulty fine for me.