I have a custom application that is using SharePoint 2010 to store list items and version those items. Search is working through the search service, and updates are successfully using the client object model. We're now trying to retrieve our custom properties for old versions of the list item to show to the user, similar to how SharePoint shows the history information, where it pulls the file version, then shows a list of the changed properties.
Right now we have the following, but the version of the file is not showing any properties available to display, even though SharePoint does show the changes when we view the history on screen.
using (ClientContext context = new ClientContext(spURL)) {
Web site = context.Web;
context.Load(site);
context.ExecuteQuery();
File file = site.GetFileByServerRelativeUrl(sRelativeObjectPath);
context.Load(file);
context.ExecuteQuery();
FileVersionCollection versions = file.Versions;
context.Load(versions);
context.ExecuteQuery();
foreach (FileVersion ver in versions)
{
File verFile = site.GetFileByServerRelztiveUrl(ver.Url);
context.Load(verFile, f => f.ListItemAllFields);
//verFile.ListItemAllFields.FieldValues are null, need to get the properties of the ListItem
}
}
Any thoughts on how I should be pulling the property values for the version? This does not run in SharePoint, so I don't have access to the SharePoint.dll to use SPQuery and SPItem.