7

Is it possible to get metadata information from a previous version of a document in a document library using a SharePoint webservice?

I know I can use the _vti_bin/Versions.asmx webservice to get information about a previous version, but can I get the previous versions metadata?

If it's not possible through webservice is it possible using Client Object Model?

  • Vedran, I need to get title of item for all versions? when i use the above method and mention title as field name , it returns collection of child nodes of all the items . So how do we get to know which title is belonging to which version? – user20852 Nov 18 '13 at 21:47
8

Versions web service is no use in your case. You need to use Lists web service (http:///_vti_bin/lists.asmx) and Lists.GetVersionCollection Method

Returns version information for the specified field in a SharePoint list.

So you need to query field by field and as far as I know there is no method to return all field versions at once.

Your code could look something like this:

WSLists.Lists listService = new WSLists.Lists();
listService.UseDefaultCredentials = true;
XmlNode result = listService.GetVersionCollection(
    "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "[ITEM ID]", "[FIELD NAME]");
string outerXml = result.OuterXml;

and outerXML looks something like this:

<Versions xmlns="http://schemas.microsoft.com/sharepoint/soap/">
  <Version [FIELDNAME]="[VALUE]" Modified="[TIMESTAMP]" Editor="[USER]" />
  .
  .
  .
</Versions>

I never used this approach but I did some tests (on SP 2010 - but I don't think there is difference). I never found good way to easily get all fields for all versions.

And Client Object Model is SP 2010 feature only but except of FileVersion Class I don't see anything similar to 'Get me item versions with metadata'.

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.