Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top