2012-02-19 58 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