Skip to main content

As a SystemAdmin with no role assigned in production,

 

Deleted parent account (which caused related event or task records deleted itself): I've run a batch, which do dml and send other sobject records to be dml in other batch from finish. I had to update the event and task records to assign a different parent account but the batch(failed) and finish continued to run another batch to delete their parent account(succeeded).

 

I used the Dynamic dml [Database.update(activitiesToUpdate, true) and Database.delete(accountsToDelete, true)]

I'm able to query those task and event records deleted implicitly with following soql

List<Task> tsks = [select id from task where isDeleted=true all rows];

system.assert(tsks.size()>0); //success

but unable to undelete them

undelete tsks; //throws an error that Those task record doesn't exist in recycle bin

FYI: i don't want to undelete parent account records, if it is required to undelete them can we remove the parent account id from record and then undelete, is this possible?

 

@* Salesforce Developers *

4 answers
  1. Dec 10, 2025, 6:46 PM

    There are certain circumstances in which a deleted record will no longer show in the Recycle Bin:

    • If the record is a child or detail in a master-detail relationship, and the parent record is deleted after the child, the child record is moved to a hard deleted status. In this scenario, the child record cannot be recovered and will need to be recreated.
    • If the record is a child or detail in a master-detail relationship and the parent record is deleted, the child record is also soft deleted but cannot be viewed in the recycle bin. In this scenario, recovering the parent record will also recover the child record. You will not be able to recover the child record without recovering the parent.

     https://help.salesforce.com/s/articleView?id=000386040&type=1

0/9000