ENTITY_IS_DELETED: entity is deleted
What does this error mean?
This error occurs when your Apex code, integration, or data operation tries to access or modify a record that has already been deleted in Salesforce.
The record may exist in the recycle bin or may have been permanently removed. Salesforce throws this error to prevent operations on records that no longer exist. [oai_citation:0‡Formyoula Support](https://support.formyoula.com/knowledgebase/articles/1085641-common-salesforce-record-errors?utm_source=chatgpt.com)
Common Causes
1. Updating a deleted record
Your code attempts to update or delete a record that was already removed earlier in the transaction.
2. Lookup reference to a deleted record
A lookup or master-detail field references a parent record that has been deleted.
3. Race condition between transactions
Another process, trigger, or integration deletes the record before your code executes.
4. Deleted record referenced in import
During data migration or integration, an ID referencing a deleted record is used. [oai_citation:1‡Salesforce](https://help.salesforce.com/s/articleView?id=000383970&language=en_US&type=1&utm_source=chatgpt.com)
How to Fix It
Solution 1 — Query existing records first
SELECT Id, Name
FROM Account
WHERE Id = :recordId AND IsDeleted = false
Solution 2 — Restore from recycle bin
If the record was deleted accidentally, restore it from the Salesforce Recycle Bin.
Solution 3 — Validate lookup IDs
if(accountId != null) {
Account acc = [SELECT Id FROM Account WHERE Id = :accountId LIMIT 1];
}
Pro Tip: Always validate record IDs before performing DML operations, especially when dealing with integrations or external systems.