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
kurtz_wolfgang_prekurtz_wolfgang_pre 

Sharing Records in Recycle Bin

Hello SFDC Gurus,

 

 

   This is out of curiosity. Does recycle bin store the sharing records? I don't think so, however Salesforce support informed us to pull the sharing records from recycle bin. Can somebody shed some light on this matter? I would greatly appreciate your input on this.

 

Thanks,

K

 

   

Best Answer chosen by Admin (Salesforce Developers) 
pjcloudpjcloud

Very good question. 

 

A quick test seems to bear out that the actual share records are there. I created an account, manually shared the account, then restored the account, which then restored the share record. If they weren't in the recycle bin, we could not restore them. 

 

Another clue that the sharing objects (AccountShare, ContactShare, Custom_Object__Share, etc.) support recycle bin functionality is the presence of an IsDeleted field. 

 

Clearly the UI does not show the share records in the recycle bin, but I'm guessing support is suggesting you use an API tool to retrieve the share records. Nice idea, and I thought I would give it a go. I would have expected it to work, and came up with this: 

 

SELECT AccountAccessLevel, AccountId, CaseAccessLevel, ContactAccessLevel, Id, IsDeleted, LastModifiedById, LastModifiedDate, OpportunityAccessLevel, RowCause, UserOrGroupId FROM AccountShare WHERE IsDeleted = true ALL ROWS

 

Unfortunately, I got an error: 

 

"MALFORMED_QUERY: ALL ROWS not allowed in this context"

That was surprising. I need to do some research about that, but fundamentally, the answer to your question is, "yes" they are in the recycle bin. But can you get to them? It does not appear so. If you want to restore them, restore their parent records. 

All Answers

sandeep@Salesforcesandeep@Salesforce

Salesforce supports to store SObject's record in recycle Bin no matter it is shared or not. 

kurtz_wolfgang_prekurtz_wolfgang_pre

Thanks Sandeep for your prompt response. However I didn't mean shared record. I need to actually specify more details about the question.

 

Contact records will have sharing information in ContactShare object. If I delete a contact record, it will end up in recycle bin, will the  ContactShare records for that particular Contact record also be stored in Recycle bin?

pjcloudpjcloud

Very good question. 

 

A quick test seems to bear out that the actual share records are there. I created an account, manually shared the account, then restored the account, which then restored the share record. If they weren't in the recycle bin, we could not restore them. 

 

Another clue that the sharing objects (AccountShare, ContactShare, Custom_Object__Share, etc.) support recycle bin functionality is the presence of an IsDeleted field. 

 

Clearly the UI does not show the share records in the recycle bin, but I'm guessing support is suggesting you use an API tool to retrieve the share records. Nice idea, and I thought I would give it a go. I would have expected it to work, and came up with this: 

 

SELECT AccountAccessLevel, AccountId, CaseAccessLevel, ContactAccessLevel, Id, IsDeleted, LastModifiedById, LastModifiedDate, OpportunityAccessLevel, RowCause, UserOrGroupId FROM AccountShare WHERE IsDeleted = true ALL ROWS

 

Unfortunately, I got an error: 

 

"MALFORMED_QUERY: ALL ROWS not allowed in this context"

That was surprising. I need to do some research about that, but fundamentally, the answer to your question is, "yes" they are in the recycle bin. But can you get to them? It does not appear so. If you want to restore them, restore their parent records. 

This was selected as the best answer
kurtz_wolfgang_prekurtz_wolfgang_pre

Thanks a lot PJCloud for the detailed explanation and the effort that you took for it. I will mark it as a solution and close this. Appreciate everybody for taking a look at this question.