10

I had more that 1,00,000 child objects records for a single record of parent Object. After deleting the child object records when I am deleting the parent record I am getting the below error:-

  • Using Apex Code : Too many records to cascade delete or set null
  • Using Salesforce Interface : Delete Operation Too Large. You can’t delete more than 100,000 combined objects and child records at the same time

I have also deleted the child records from the recycle bin. Still I am getting the same error.

Could anyone please guide me how to resolve this issue.

1
  • I'm also facing this error too when deleting from Dataloader (when all my related records have been deleted) too. Nothing updated till now on this issue? It's 2017 already...
    – compski
    Commented Apr 10, 2017 at 4:43

2 Answers 2

11

You must wait between several days up to a week in order to delete the parent record. Even if you empty the recycle bin, the records are not "permanently" deleted until some reaper job on the Salesforce side runs to truly delete them.

If you're in a rush, you can open a case with Salesforce asking to "run a physical delete" on your org. They will require that you agree to empty your recycle bin first.

The deleted records don't count toward your data storage limit.

We have worked around this problem by setting a 'status' field on the parent object to indicate that we want it deleted. After we delete all of the child records, we set the status to 'Deleting'. Then, create a Scheduled Apex job that runs around nightly trying to delete the parent records that are in that status. You must rescue the possible exception and carry on. Sooner or later, the records can be deleted.

Last caveat: sometimes the org gets corrupted and even the 1 week rule doesn't hold true. In that case, you will need to open a case and have them escalate it to R&D for physical deletion. This is rare, but it does happen.

The bit of Scheduled Apex we use looks something like:

List<SupremeQueryResult__c> deletedSnapshots = [SELECT Id FROM SupremeQueryResult__c
                                                WHERE Status__c IN('Deleted','Deleting')];
for(SupremeQueryResult__c result : deletedSnapshots){
    try{
        delete result;
    }
    catch(System.DmlException dmle){
        if(dmle.getDmlType(0) != StatusCode.DELETE_OPERATION_TOO_LARGE){
            throw dmle; //reraise
        }
    }
}
4

I found this related thread on the Developer Boards. I can't say for certain that it works this way, but from reading that thread it appears like Salesforce queues up these delete operations on the back end. It sort of makes sense since there needs to be logic to go through all of those records and remove attachments, notes, tasks, etc.

My suggestion at this point would be to log a case (https://help.salesforce.com/apex/HTHome -> Contact Support -> Open a Case) to see if you can get an official response from Salesforce, but potentially wait a day or two and then attempt to delete the parent record.

2
  • I have no attachments or notes. Will raise a case to support team Commented Nov 5, 2014 at 12:54
  • 1
    @SalesforceLearner My point was that Salesforce still needs to run through all of that logic (since it doesn't know if the records you do or not until it checks them), so that may be why it gets queued up. I could be wrong though, that was just a guess. Commented Nov 5, 2014 at 12:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .