tags:

views:

24

answers:

1

Hi Everyone,

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 = workflowProperties.List.ContentTypes["ContentType 2"];

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

I'm thinking this will work but not sure.

Thanks, JJ

+1  A: 

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"

naivists