There is a SharePoint List from which many records have been deleted using CAML. The records are available in the Recycle Bin.

Is there an way to recover the records using scripting/CAML etc ? Since it's not efficient to recover the records manually.

Regards, André


This code will restore all the items deleted from the specified list:

string listUrl = "web/relative/list/url"; // without leading slash!
var toRestore = new List<SPRecycleBinItem>();
foreach (SPRecycleBinItem recycleBinItem in web.RecycleBin)
    if (recycleBinItem.ItemType == SPRecycleBinItemType.ListItem
        && recycleBinItem.DirName.ToLowerInvariant() == listUrl.ToLowerInvariant())

foreach (var itemToRestore in toRestore)

Note: this code will require elevated privilegies, if you want to allow ordinary portal users to use it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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