I have some code which I am attempting to use to "rollback" a sharepoint document and it's metadata properties to a previous version using ootb version control and the SharePoint API. Here is a sample of my code:
int versionCount = item.Versions.Count;
if (versionCount > 0)
{
// this only restores properties
item.Versions.Restore(1);
}
The expected result of calling restore using 1 (the newest version before the current version) would be to restore the file and metadata. Instead, only the metadata is restored and the current file is copied to the new "restored" version.
The versions page clearly displays multiple versions and restoring through the UI restores the desired file.
Furthermore, I have attempted to use item.File.Versions
only to find item.File.Versions.Count
is 1.
Can anyone provide any insight?