2012-02-19 53 views
0

在启用次要版本的文档库中,UpdateOverwriteVersion()创建次要版本。SPListItem.UpdateOverwriteVersion创建次要版本?

线程 - http://social.technet.microsoft.com/Forums/en-US/sharepointgeneral/thread/e0d1af63-3705-4b58-95c5-f0f92f86a23f - 解释类似的问题,并提出解决方案,关闭次要版本,更新项目并打开次要版本。

但是,我无法暂时关闭小版本设置,因为其他用户可能正在使用相同的库上载/更改其文档,并且关闭设置可能会影响其操作。

有没有其他解决方案?

感谢和问候,

Arjabh

回答

1
If the goal is to update the fields without creating multiple versions see the code: 

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

CheckinType.OverwriteCheckIn不会为我工作。无论如何,它会创建新的小版本。至少在SharePoint 2010中有效。 – 2012-08-31 11:15:29

1

尝试listItem.SystemUpdate代替listItem.UpdateOverwriteVersion(假)()

+0

这有效,但对我有一点缺点。它附加了对版本历史中最后一个现有版本的更改,这可能会让人感到困惑。 – 2012-08-31 11:17:43