3

Is there a way to capture the previous version history of list items (probably based on the version number) using CSOM?

3

In SharePoint 2013 on premise, we cannot get the version history by CSOM. CSOM does not provide such API.

As a workaround, we can use the SharePoint web service.

For more detailed information, you could refer to the post below.

There is a similar post:

https://social.msdn.microsoft.com/Forums/SqlServer/en-US/177ceafb-debd-4020-b943-904c220cbf5f/how-to-get-list-item-versions-using-csom?forum=appsforsharepoint

2

You can do it in SharePoint Online via the CSOM, if you have later than the September 2017 version.

Each ListItem will have a Versions property, which is of type ListItemVersionCollection. If you loop through these versions each ListItemVersion inside will have a FieldValues and you can fetch your data from these.

 foreach (var version in item.Versions)
 {                        
       string versionLabel = version.VersionLabel;
       string versiondate = version.FieldValues["Modified"].ToString();
       string AssignedTo = ((FieldUserValue)version["AssignedTo"])?.LookupValue ?? "";                       
 }

https://dev.office.com/blogs/new-sharepoint-csom-version-released-for-Office-365-september-2017

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.