Question

I'm trying to figure out a way, using the Sharepoint Client Object Model, to get the content type and the metadata values of a listItem at a specific version.

I can get the different versions using ListItem.File.Version, but once I get that I didn't find any way to get a File or a ListItem that would allow me to know what was the content type of the item when it was at that version and what were the values of the column associated with that content type for that item.

I tried this:

Microsoft.SharePoint.Client.File verFile = clientContext.Web.GetFileByServerRelativeUrl(versionItemUrl);
clientContext.Load(verFile, f => f.ListItemAllFields);
clientContext.ExecuteQuery();

But I always get the following error message: Specified value is not supported for the serverRelativeUrl parameter.

I've also read a bit about the List.GetVersionCollection Method which might be the solution even if I have to make a service call for each column I need. But then again, how do I get the content type of my item at that version? I need it to figure out which columns I want the value of.

Any help appreciated. Thanks in advance!

Was it helpful?

Solution

As I didn't find any faster way of doing it, I figured that using the List Service method GetVersionCollection es the only way to go. I'll start by getting the ContentTypeId field History and the _UIVersionString field history. From that I will be able to get the content type at a specific version, which will give me the columns I want to get next. Sadly this means I'll have to make a bunch of service calls but it seems to be the only way.

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