Update ListItem from Client Objectmodel without changing the version
Is it possible to update the Created/Modified fields using the Sharepoint Client ObjectModel without updating the version?开发者_运维知识库
var file = _ClientContext.Web.GetFileByServerRelativeUrl(serverRelativeUrl);
_ClientContext.Load(file);
_ClientContext.ExecuteQuery();
ListItem listItem = file.ListItemAllFields;
listItem["Created"] = info.SourceFile.CreationTime;
listItem["Modified"] = info.SourceFile.LastWriteTime;
MapMembers(listItem, info.MetaData);
listItem.Update();
listItem.SystemUpdate / Update(false) is not available in the Client ObjectModel.
Thanks
Microsoft.SharePoint.Client.File lp_newFile = lp_web.GetFileByServerRelativeUrl(lp_uri.LocalPath);
lp_context.Load(lp_newFile);
lp_context.ExecuteQuery();
//check out to make sure not to create multiple versions
lp_newFile.CheckOut();
ListItem lp_item = lp_newFile.ListItemAllFields;
listItem["Created"] = info.SourceFile.CreationTime;
listItem["Modified"] = info.SourceFile.LastWriteTime;
listItem.Update();
// use OverwriteCheckIn type to make sure not to create multiple versions
lp_newFile.CheckIn(string.Empty, CheckinType.OverwriteCheckIn);
精彩评论