开发者

Update ListItem from Client Objectmodel without changing the version

开发者 https://www.devze.com 2023-03-16 22:37 出处:网络
Is it possible to update the Created/Modified fields using the Sharepoint Client ObjectModel without updating 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);
0

精彩评论

暂无评论...
验证码 换一张
取 消