ENTITY_IS_DELETED: entity is deleted
You tried to update or query a record that's in the recycle bin (soft-deleted). Either undelete it first, query with `ALL ROWS` to include deleted records, or fix the upstream that's pointing at a deleted ID.
Also seen asENTITY_IS_DELETED·entity is deleted·ENTITY_IS_DELETED: entity is deleted
Salesforce records aren't immediately purged when deleted — they go into the recycle bin for 15 days. During that window, they're "soft-deleted": invisible to normal queries, immutable from normal DML.
What this error means in practice
delete acct; // moves to recycle bin
acct.Name = 'New';
update acct; // ENTITY_IS_DELETED
Or, more common in integrations: an external system pushes a record by ID, but that ID was deleted between when the external system fetched it and when it tries to update. The push fails with this error.
How to handle it
Option 1: undelete before updating
If the deletion was accidental, restore it:
Database.UndeleteResult result = Database.undelete(deletedId);
if (result.isSuccess()) {
Account a = [SELECT Id FROM Account WHERE Id = :deletedId];
a.Name = 'New';
update a;
}
Option 2: detect and skip
In a sync integration, the right behaviour is often to skip the deleted record and log it for review:
try {
update extEntity;
} catch (DmlException e) {
if (e.getDmlStatusCode(0) == 'ENTITY_IS_DELETED') {
Sync_Log__c log = new Sync_Log__c(
Record_Id__c = extEntity.Id,
Status__c = 'Skipped — deleted in Salesforce',
Synced_At__c = System.now()
);
insert log;
} else {
throw e;
}
}
Option 3: query with ALL ROWS
If you need to see deleted records (e.g., for an audit report), use Database.queryAll:
List<Account> all = Database.query('SELECT Id, Name, IsDeleted FROM Account', AccessLevel.SYSTEM_MODE);
// or
List<Account> deleted = [SELECT Id, IsDeleted FROM Account WHERE IsDeleted = true ALL ROWS];
ALL ROWS includes records in the recycle bin. Useful for batch jobs that audit the recycle bin.
A common cause: cascading deletes
When a parent in a master-detail is deleted, all children are also soft-deleted. If your integration tracks records by Id, deleting the parent invisibly invalidates many child IDs at once. Test for this in your integration by checking IsDeleted periodically.
After 15 days
Once a record is hard-deleted (passed the 15-day window or explicitly emptied from recycle bin), the ID returns INVALID_CROSS_REFERENCE_KEY, not ENTITY_IS_DELETED. The platform doesn't keep the soft-deleted entry around forever.
For records you might need to recover later, the org-wide setting "Increase Recycle Bin Retention to 30 days" doubles the window. Beyond that, you need a backup tool.
