RESTOREVERSION

Used to restore a specific version of a specific document in a document library. This will replace the current version of the document with the restored version.

Syntax

resultset RESTOREVERSION(string listName, string file, double version);

Return value

After restoration the procedure returns a list of versions with the following columns.

Column.NET Data TypeDescription
Version System.String Version number, e.g. "1.0". Current version always starts with '@'.
Url System.String The full URL of the document version
Created System.DateTime Date of creation
CreatedBy System.String Name of creator
Size System.String Size of document
Comments System.String Optional comments provided by the creator

Example: to restore version 2.0 of document Cats.docx from folder Latest in library Animals:

CALL RESTOREVERSION('Animals', 'Latest/Cats.docx', 2.0);

Code examples

Restore document version

using (var connection = new SharePointConnection(connectionString))
{
    connection.Open();
    using (var command = new SharePointCommand(@"CALL RESTOREVERSION('Shared Documents', 'Files/Serverlist.txt', 1.0)", connection))
    {
        using (var reader = command.ExecuteReader())
        {
            while (reader.Read())
            {
                Console.WriteLine("Version: " + reader["Version"].ToString());
                Console.WriteLine("Created: " + reader["Created"].ToString());
                Console.WriteLine("CreatedBy: " + reader["CreatedBy"].ToString());
            }
        }
    }
}

Code result

Version: @3.0
Created: 2013-01-12 16:01:12
CreatedBy: Adam Sandler
Version: 2.0
Created: 2013-01-12 15:12:54
CreatedBy: Abe Lincoln
Version: 1.0
Created: 2013-01-12 07:16:26
CreatedBy: Abe Lincoln


Skip Navigation Links.

Visa     MasterCard