You need to sign in to do that
Don't have an account?
System Integration 35
Apex trigger for Lead to Contact
I'm trying to update a custom field (Conversion_Type) from Lead to Contact, any ideas why it's not updating?
trigger LeadConvType on Lead (after insert) { Map<Id,String> Conversion_Type = new Map<Id,String>(); // Map of the converted Contact ID and the Lead Status for(Lead lead : Trigger.new) { if (lead.IsConverted) { Conversion_Type.put(lead.ConvertedContactId,lead.Conversion_Type__c); } } List<Contact> conContacts = [select Id from Contact WHERE Contact.Id IN :Conversion_Type.keySet()]; for (Contact c : conContacts) { c.Conversion_Type__c = Conversion_Type.get(c.Id); } update conContacts; }
You are doing one mistake here. Your Trigger Events should be "After Update" instead of "After Insert".
If it was helpful, Please mark this as Best Answer so that it may help others as well.
Thanks,
Sandeep Singhal
http://www.codespokes.com/
All Answers
You are doing one mistake here. Your Trigger Events should be "After Update" instead of "After Insert".
If it was helpful, Please mark this as Best Answer so that it may help others as well.
Thanks,
Sandeep Singhal
http://www.codespokes.com/