0

I am trying to copy files from one site collection to another including their version history and preserve the metadata using CSOM. I am almost there using the below logic for each version of the file. However I am not able to get this to work for major/published/X.0 versions.

1) Check out existing file (If not first version uploaded)

2) Upload the file version

3) Assign the document metadata and perform a checkin (either major or minor to match original files version history).

4) Use ValidateUpdateListItem to set the Editor and Modified values as they were overwritten by the checkin in step 3

This works in most scenarios and keeps the modified date. However if the version was a published version and minor versions are enabled this creates a new X.1 version.

Does anyone have a way of updating the Editor for a published version with minor versions enabled on the list that does not affect the version number? The only solutions I have found require server side code or temporarily disabling versioning which I cannot do!

Requirements:

CSOM only - this is client side C# code.

I cannot temporarily enable/disable versioning or minor versions on the library.

0

Download the latest CSOM dll from nuget(minimum 16.1.5626.1200 or above). In that, the SystemUpdate method has been added.

After referencing that dll in your project, in your CSOM code, instead of listItem.Update() use listItem.SystemUpdate().

It allows you to update a list item without changing modification date, author, publishing and versioning information.

Reference - SharePoint CSOM August 2016 update

  • 1
    I have given this a go and it does now set the Editor correctly without incrementing the version. However it is not saving the modified date I set. Ths means the versions show as modified when I checked them in instead of their original modified dates. Am I missing something? Also is there any way of doing this with SharePoint 2013 as it does not have this method? Thanks! – Chris.Overton Dec 1 '16 at 11:10

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.