title: Salesforce Lead Trigger CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
body: <p>I want to clone the Profile__c record. The lead has a profile__c associated with it. When conversion happens, the Profile_c on the lead is copied to the account created. What I need to do is a deep clone of the Profile__c on the new account  created after the conversion. I am able to copy the profile_c over but cloning throws this error:</p>
  
  <p>Error: System.DmlException: Update failed. First exception on row 0 with id 00QJ0000007dDmHMAU; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, profile: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: [] Trigger.profile:, column 1: [] (System Code)</p>
  
  <pre><code>trigger profile on Lead (after update) {
  
  Map&lt;Id, Lead&gt; cl = new Map&lt;Id,Lead&gt;();
  Lead parent;
  List&lt;Contact&gt; clist = new List&lt;Contact&gt;();
  Set&lt;Id&gt; convertedids = new Set&lt;Id&gt;();
  
  //list of converted leads
  for (Lead t:Trigger.new){
      Lead ol = Trigger.oldMap.get(t.ID);
      if(t.IsConverted == true &amp;&amp; ol.isConverted == false)
      {
          cl.put(t.Id, t);
          convertedids.add(t.ConvertedContactId);
      }
  }
   Set&lt;Id&gt; leadIds = cl.keySet();  
  
    List&lt;Profile__c&gt; mp = [select Id, lock__c, RecordTypeId, reason__c, End_Date__c,startus__c , Opportunity__c, Account__c, Lead__c from Profile__c where Lead__c in :leadIds];
    List&lt;ID&gt;AccountIDs = new List&lt;ID&gt;();
    List&lt;Profile__c&gt;clonedList = new list&lt;Profile__c&gt;();
    for (Profile__c mpi:mp){
      parent = cl.get(mpi.Lead__c );
      mpi.opportunity__c = parent.ConvertedOpportunityId;
      mpi.account__c = parent.ConvertedAccountId;
      AccountIDs.add(parent.ConvertedAccountId);
      Profile__c profile = mpi.clone(false,true,false,false);
      clonedList.add(profile);
      mpi.lock__c= true;
      mpi.reason__c= 'Converted';
    }
   update mp;
   insert clonelist
  }
  </code></pre>