title: Salesforce Apex Convert Leads with the same AccountId "Duplicate id in list: "
body: <p>Is there a standard way of converting Leads with the same AccountId in Salesforce.  When trying to do it with the following code, I get the error "Duplicate id in list"</p>
  
  <pre><code>List&lt;Database.LeadConvert&gt; leadConverts = new List&lt;Database.LeadConvert&gt;();
  for(Lead myLead : leadsToConvert){
      Database.LeadConvert lc = new database.LeadConvert();
  
      if (accountMap.get(myLead.Company) &lt;&gt; null) {
  
          lc.setLeadId(myLead.Id);
          lc.setDoNotCreateOpportunity(true);
          lc.setAccountId(accountMap.get(myLead.Company).id);
          lc.setOverwriteLeadSource(true);
  
          //if we match to a contact, merge
          if (contactMap.get(myLead.Email) != null &amp;&amp; myLead.Email != null) {
              lc.setContactId(contactMap.get(myLead.Email).id);
          }               
  
          lc.setConvertedStatus(convertStatus.MasterLabel);
          leadConverts.add(lc);           
      }
  }
  
  if(!leadConverts.isEmpty()){
      Database.convertLead(leadConverts, false);
  }
  </code></pre>
  
  <p>This code only fails when I pass in a List of leads that have the same AccountID.  I get the "Duplicate id in list" error.</p>
  
  <p>Why can I not do this?<br>
  Is there a standard practice/ way to avoid this?</p>