1

I have a stack of documents i need to upload into sharepoint they are all different versions of the same document.

i'm planning to upload each document into SharePoint and make them different versions.

example of document names :

Doc 1- feb 1 2016.docx
Doc 1- feb 2 2016.docx
Doc 1- feb 3 2016.docx

i want to have in sharepoint

doc1.docx

and looking at the version history

Version 3 - feb 3 2016
Version 2 - feb 2 2016
Version 1 - feb 1 2016

Is it possible to do this with CSOM ? or would i need SSOM or powershell ?

Additionally can this be done also for SP Online ?

0
+100

In SharePoint 2016 there is no possibility to update an item without changing the version number when using CSOM.

However in SharePoint Online there is a method called UpdateAndOverwriteVersion which may perform the action you are trying to do. In combination with the SystemUpdate method this might be possible.

Unfortunately there is not much documentation regarding these methods.

https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.listitem.systemupdate.aspx

https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.listitem.updateoverwriteversion.aspx

But as you state in your own answer one possibility is to disable versioning, then change the date and then re-enable versioning. It's tedious but it does the job. If I were you i would go on

another approach was to always delete the previous version to the last one, but this would have a double incremental gap between versions

If its not a big deal to have versions that jump 2 versions each time.

  • UpdateOverrideVersion did the trick! but it takes longer than disabling and enabling versioning, LOL, but i trust this method more as it won't mess with the possible side effects of disabling versioning – Mike Jul 5 '18 at 18:11
0

Accomplished this by using CSOM and setting the modified date.

the problem with this is that making changes to the document using csom would generate two versions, the original one and the one with the modified date.

to avoid this after uploading the document i disable versioning, then I change the date and then I re-enable versioning.

another approach was to always delete the previous version to the last one, but this would have a double incremental gap between versions

  • you can prevent version update by using item.SystemUpdate() method of CSOM. It works in SPO not in 2016 On Prem – Gautam Sheth Jul 5 '18 at 13:52
  • item.SystemUpdate() won't work when the field that you are trying to change is the "modified" date field as item.SystemUpdate() invokes the modified date of the current version to keep them the same as the old one... LOL ! – Mike Jul 5 '18 at 14:14
  • true that, my bad ! Sorry, can you check with using validateUpdateListItem method ? Looks like it will do the job ! – Gautam Sheth Jul 5 '18 at 14:50

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.