2010-09-22 58 views
0

我需要更改Sharepoint工作流程中的ContentType。如果我設置下面這個會改變它嗎?如果不是如何。如果我目前正在使用ContentType 1作爲List,並且想要切換到使用ContentType 2,那麼我需要什麼代碼才能實現此目的?更改ContentType - VS2008中的SharePoint工作流程

SPListItem currentItem = workflowProperties.Item; 
SPContentType myCType = workflowProperties.List.ContentTypes["ContentType 2"]; 

     currentItem["ContentTypeId"] = myCType.Id; 
     currentItem.Update(); 

我在想這會工作,但不知道。

感謝, JJ

回答

1

看起來好像沒什麼問題。最後我會打電話給currentItem.SystemUpdate(),因爲這會使'修改日期'和'修改'字段不變。如果您只是致電Update,它將顯示由「Sharepoint \ system」修改的項目