In Salesforce, Lead is converted is a standard feature. This is an important one in business requirement. After a lead is qualified then it will be converted into account, contact, opportunity through Convert button. By default some information like that phone number, address are updated from the converted lead.
Customer some times asked, they want to update some information in contact, account, opportunity. In that situation, the below code will help you and we have tried in Fieldax&Field Service Management.
For Example,
Here we update field (Level) value is ‘Secondary‘ in contact after the lead is converted.
Try the below code –
public void UpdateContact(Map<id,Lead> newmap){ Set<Id> setContact = new Set<Id>(); for(Lead l:newmap.values()){ if(l.isConverted && l.ConvertedContactId!= null){ system.debug(l.isConverted+'+++'+l.ConvertedContactId); setContact.add(l.ConvertedContactId); } } if(setContact.size()>0){ List<Contact> upcontact=new List<Contact>(); for(Contact c:[select id,name from Contact where id in:setContact]){ if(c.id!=null){ c.Level__c='Secondary'; upcontact.add(c); } } if(upcontact.size()>0){ update upcontact; } } } We are the ISV Partners and Please reach us for custom development => www.merfantz.com ------------- We Hope this will help you -------------