Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need know old id of item in recycle bin or is there any way how to save its id in this item before deleting. When item is deleted, a new SPRecycleBinItem is created in Recycle Bin. And the only saved information about old item is DirName. But I need know more information.

share|improve this question
add comment

migrated from stackoverflow.com Jun 18 '12 at 15:10

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 1 down vote accepted

I have solved this issue. There is such property as LeafName in SPRecycleBinItem, which is the same as earlier Id in SPListItem for files (not for folders). If SPListItem was a file, then its LeafName would be "id" + "_.000" after deleting; If SPListItem was a folder, then its LeafName would be earlier Name of SPListItem.

share|improve this answer
add comment

Well, you can of course save an items ID in an event receiver when deleting it and store it where you can relate it to an item in the recycle bin.

However, by the sound of this I think you're using an Item ID as a primary key, and have now run into the problem of the ID changing. Using item ID as a key is a very bad idea, as it will change when doing item level restore through backup tools, when recycling it, and depending on how you use it; with version control.

TL;DR - Yes, you can use an event handler to store the ID before recycling, but using the ID for anything is a really bad idea.

share|improve this answer
    
Yes, I can save GUID of deleted items, but this collection of GUIDs will never be cleaned, when item is deleted from Recycle Bin. –  andDaviD Jun 18 '12 at 13:39
    
Fairly sure that ItemDeleting, if connected to the content type, is fired when you remove something from the recycle bin. Not 100% sure, but you should check. –  Tobias Jun 19 '12 at 6:58
    
I have already checked it. There aren't any EventReceivers for Recycle Bin. Developers of sharepoint didn't create them ( –  andDaviD Jun 19 '12 at 7:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.