function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
markus.muellermarkus.mueller 

Deleting objects that are in a Master-Detail relationship

Hi,

 

I have just noticed a behaviour that seems strange to me.

 

 

Consider the following scenario:

- MasterCustomObject__c

- DetailCustomObjectA__c (related with MasterCustomObject__c)

- DetailCustomObjectB__c (related with MasterCustomObject__c)

 

 

 

Now consider the following actions that are performed consecutively:

 

1. If I delete DetailCustomObjectA__c, it is naturally thrown into recycle bin and cannot be queried via SOQL (everything is clear at this point)

 

2. If I delete MasterCustomObject__c afterwards, it is thrown into recycle bin.

  2.1 DetailCustomObjectB__c is not visible in recycle bin

  2.2 DetailCustomObjectA__c  -  which has been deleted in (1)  -  is no longer visible in recycle bin

 

3. After undeleting MasterCustomObject__c from recycle bin, the situation is as follows:

  3.1 MasterCustomObject__c is available again

  3.2 DetailCustomObjectB__c is accesible again

  3.3 but DetailCustomObjectA__c remains lost, i.e. it cannot be queried via SOQL nor is it visible in recycle bin.

 

 

 

I would have expected, that after deleting Master-Detail objects - no matter of chronological order of deletion and undeletion - all objects had to be back again.

Is there any explanation for the observed behaviour or even an option to fix this problem?

 

Thanks in advance for any assistance!

AditiSFDCAditiSFDC
Hi,
This is the expected behavior of master-detail relationship.
When you delete DetailCustomObjectA__c then MasterCustomObject__c left with only a single child i.e DetailCustomObjectB__c.
When you undelete Master, then only connected child will we connected back not the one which are deleted way back in past deliberately by user.

Hope this make sense and answer your question. :)
markus.muellermarkus.mueller

Hi Aditi,

 

thank you very much for your reply. I see your point. It sounds clear that only connected detail objects are recovered in case that a master object is undeleted.

But, in my honest opinion, it's not entirely clear why deleting a (even though former connected) master object impairs the recycle bin entry of the detail object that has been deleted first, because these two actions don't actually belong together.

 

If the detail object entry would remain in recycle bin, you would be able to recover that detail object (provided that the master object has already been recovered).

 

So, am i correct in assuming there is no possibility to change that behaviour?!

 

Thanks anyway :-D

Markus