I'm trying to programmatically upload a file to SharePoint (2016)/ office 365 and modify the Created by /Modified by and also add a history comment along with this operation. The idea is I cannot make those things work together in the same operation.

I can modify the created by with the following code.

uploadFile.ListItemAllFields["Editor"] = userValue.Id;
uploadFile.ListItemAllFields["Author"] = userValue.Id;

But in order to add a history comment I must check out/check in the file.

uploadFile.CheckIn("Just a history comment", CheckinType.OverwriteCheckIn);

This overrides my previous changes and my Author and Editor is set to my account, doesn't matter what I do.

There are other approaches that I'm missing ?

  • So, just to confirm since you only mention this in the tags - you are using Client side object model against a SharePoint online 2016 farm? – BlueSoul Jun 19 '16 at 14:34
  • Yes .I'm using client side object model. – Cosmin2509 Jun 19 '16 at 14:52
  • Thanks, I wanted to be sure. I can't really think of a way to achieve this (CSOM doesn't support .SystemUpdate() ) but let me check anyway. Will report if I can find something noteworthy. – BlueSoul Jun 19 '16 at 15:01
  • What about user impersonation? Is a user defined in config or is a variable user depending on context, time, whatever? – Paolo Jun 19 '16 at 18:03
  • The user is variable that get from database.... A solution in this case can be to put a custom password for all users and after the operation is done to force the users to change their passwords. – Cosmin2509 Jun 19 '16 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.