+ Start a Discussion
Harold CrouseHarold Crouse 

ConvertedAccountID on Lead not matching report

So I'm trying to run a script that takes converted leads and copies their created date onto a field on the created account and I'm finding some strange things.  Well things I thought weren't strange until I started investigating more.  Script is simple
 
map<id,DateTime> accountsWithDate = new map<id,DateTime>();
For(Lead l: [Select ConvertedAccountID, CreatedDate from Lead where IsConverted = true]){
      AccountsWithDate.put(l.ConvertedAccountID,l.CreatedDate);
}
list<Account> accounts = new list<Account>();
for(Account a [Select id, Lead_Creation_DAte__c from Account where Id in: accountsWithDate.get(a.id)){
      a.Lead_Creation_Date__c = accountsWithDAte.get(a.id);
      accounts.add(a);
}
update accounts;

So as expected I'm finding multiple leads that contain the same ConvertedAccountID, I assume from converting a duplicate lead and chooseing merge into existing account.  However when I run the leads with converted information report and include Account ID as converted Account ID is not available on the report;  I see two different Accounts?

Results from the report:
 User-added image
Results from the query
User-added image

I'm not sure what is happening here?  Anyone have any insights?