CreateTaskWithContentType class

Defines a workflow activity that is used to create a task item in a Microsoft SharePoint Foundation 2010 task list, using a specified SharePoint Foundation 2010 content type.

Namespace:  Microsoft.SharePoint.WorkflowActions
Assembly:  Microsoft.SharePoint.WorkflowActions (in Microsoft.SharePoint.WorkflowActions.dll)

[ToolboxBitmapAttribute(typeof(CreateTaskWithContentType), "Resources.CreateTaskWithContentType.bmp")]
[ActivityToolboxDisplayAttribute("VSTTSharePointWorkflowTask", true)]
public sealed class CreateTaskWithContentType : CallExternalMethodActivity

You must ensure that content types are enabled on the SharePoint Foundation task list where you are creating the task list items. If they are not enabled on this list, the activity will throw a a null reference (Nothing in Visual Basic) reference exception.

MVP Icon

The following code sample was contributed by Robert Bogue, one of the SharePoint Foundation MVPs.

Get to know your SharePoint Foundation MVPs on this Web site.

The following code sample updates a content type.

public static void VerifyModifyTaskList(SPList taskList, string contentType)
      SPContentTypeId contentTypeId = new  
   taskList.ContentTypesEnabled = true;
                SPContentTypeId matchContentTypeId = taskList.ContentTypes.BestMatch(contentTypeId);
                if (matchContentTypeId.Parent.CompareTo(contentTypeId) != 0)
                    SPContentType ct = taskList.ParentWeb.AvailableContentTypes[contentTypeId];

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.