开发者

Change ContentType - SharePoint Workflow in VS2008

开发者 https://www.devze.com 2023-01-17 08:33 出处:网络
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 Content

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"

0

精彩评论

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