We currently have a web form that connects to leads in Salesforce - The issue with this is that we are finding that we have contacts with the same email address/similar names.

It is possible in apex to use the merge method on leads and contacts in the same DML?


Merge contact Lead
  • Why you are not using the Contacts-Leads standard matching rules? That should take care of the duplicate / merge problem for you.
    – Mahmood
    Feb 26 '20 at 17:16

No. To convert a lead to a contact, use the Database.convertLead method.

  • Should I convert the lead and then use the merge method? Feb 26 '20 at 17:26
  • 1
    @MatthewMetros You can convert directly to the existing contact, no merge call is required.
    – sfdcfox
    Feb 26 '20 at 17:30
  • Does it do this based on the email? I am assuming, but just checking Feb 26 '20 at 18:03
  • @MatthewMetros The logic in Apex is left up to you. You can perform whatever type of matching algorithm you'd like.
    – sfdcfox
    Feb 26 '20 at 18:06
  • I think you misunderstood my question - I am looking to see if we can merge leads and contacts using the merge statement in apex. If we cannot do this, should I first convert the leads and then merge them from there using whatever logic? Feb 26 '20 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.