Share via

Any correlation between RecycleBinItem and ChangeItem/ChangeFolder?

Rudy Menjivar 26 Reputation points
2022-03-03T16:00:37.773+00:00

Not sure if I'm in the right place for this question.

We're getting changes made to lists and document libraries using the C# Microsoft.SharePoint library. These changes include items that have been deleted. For the deleted items, I'm trying to find a way to get data on this item from the RecycleBinItemCollection, but I'm not sure how to query for this item.

A simpler approach I'd like to have is to get all the information from ChangeItem/ChangeFolder object (e.g., the item name and editor name), but this is how I came to the RecycleBinItemCollection. The problem here is being able to identify the item in this collection using fields from ChangeItem/ChangeFolder.

So far, what I have is ChangeItem.ItemId that I can query for using RecycleBinItemCollection.LeafName, but that's not a unique field we can use:

RecycleBinItem result = RecycleBinItemsResults.OrderByDescending(x => x.DeletedDateLocalFormatted)
                                            .Where(x => x.LeafName.Substring(0, 1).ToInt32() == ((ChangeItem)change).ItemId )
                                            .FirstOrDefault();

I'll be cleaning up the lambda expression later, just testing with this single instance for now.

Microsoft 365 and Office | SharePoint | Development
0 comments No comments

Answer accepted by question author

RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
2022-03-04T07:36:26.23+00:00

Hi @Rudy Menjivar ,
Per my research, there is no correlation between RecycleBinItem and ChangeItem/ChangeFolder. I have tested RecycleBinItem.Id by following code.

    RecycleBinItemCollection rbiColl = web.RecycleBin;  
    ctx.Load(rbiColl);  

    ctx.ExecuteQuery();  

    foreach (RecycleBinItem rbiItem in rbiColl)  
    {  
        var ribid = rbiItem.Id;  
        Console.WriteLine(rbiItem.Title);  
        Console.WriteLine(rbiItem.Id);  
    }  
    Console.ReadLine();  

179930-image.png
The RecycleBinItem.Id is a UniqueId differs from ChangeItem.ItemId. And I also tested ChangeItem.UniqueId but with no luck. We are unable to map RecycleBinItem to ChangeItem for their UniqueId is different.

I feel regretful to inform you that it turns out to be a by-design one.

And I noticed that some end users have also proposed the same request, it is highly recommended that you can vote this ticket. Many features of our current products are designed and upgraded based on customers’ feedback. With requirements like this increase, the problem may well be released in the future. Thanks for your understanding.


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Rudy Menjivar 26 Reputation points
    2022-03-04T20:31:43.393+00:00

    @RaytheonXie_MSFT ,

    Thanks for this. I submitted my request to the forum. Is there any other way to get this data where I can either get Title and DeletedBy in the ChangeItem object where the ChangeType is DeleteObject?

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.