We have a requirement to delete all converted leads whose corresponding contacts have been deleted. Upon implementation we noticed something odd:
After creating and converting a lead via UI (classic only in this case) we deleted the contact again (and emptied the recycle bin).
Now, after executing the following SOQL query,
SELECT Id, Name, Status, IsConverted, ConvertedContactId, ConvertedContact.Name FROM Lead WHERE IsConverted = true
- There is still a contact ID stored in
ConvertedContactId(even though the corresponding contact has been deleted)
- The relationship query to
For me this seems very odd, since I don't know about any other situation where Salesforce would keep an ID to a deleted record in a reference field.
My questions now:
- Can anybody explain this behaviour?
- Does Salesforce (at some point) clear the
ConvertedContactIdfield (since I found some converted leads without any value in that field in our production org and the only way to convert a lead for our business user is via Standard Classic UI)
- Is there another reliable and straight-forward way for a nightly batch to identify leads whose conversion-contacts have been deleted during the day?
Edit Jul 10 2018: one more thing: After a couple of days, the ID of the deleted contact is actually removed from the converted lead. I did not try to determine the exact time though.