Change ContentType - SharePoint Workflow in VS2008
I need to change the ContentType in my Sharepoint workflow. If I set the following will this change it? If not how. If I am presently using ContentType 1 for a List and want to switch to using ContentType 2 what code do I need in order to make this happen?
SPListItem currentItem = workflowProperties.Item;
SPContentType myCType = wor开发者_开发技巧kflowProperties.List.ContentTypes["ContentType 2"];
currentItem["ContentTypeId"] = myCType.Id;
currentItem.Update();
I'm thinking this will work but not sure.
Thanks, JJ
Looks fine to me. I would call currentItem.SystemUpdate() in the end, since this leaves the 'modified date' and 'modified by' fields untouched. If you simply call Update, it will show the item as modified by "Sharepoint\system"
加载中,请稍侯......
精彩评论