Click to Rate and Give Feedback
Community Content
In this section
Statistics Annotations (0)
Collapse All/Expand All Collapse All
This page is specific to
The 2010 product release

Other versions are also available for the following:
CreateTaskWithContentType Class

[This documentation is preliminary and is subject to change.]

Creates 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)
Visual Basic (Declaration)
<ToolboxBitmapAttribute(GetType(CreateTaskWithContentType), "Resources.CreateTaskWithContentType.bmp")> _
<ActivityToolboxDisplayAttribute("VSTTSharePointWorkflowTask", True)> _
Public NotInheritable Class CreateTaskWithContentType _
    Inherits CallExternalMethodActivity
Visual Basic (Usage)
Dim instance As CreateTaskWithContentType
C#
[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 nullNothingnullptra 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.

C#
public static void VerifyModifyTaskList(SPList taskList, string contentType)
{
   try
   {
      SPContentTypeId contentTypeId = new  
      SPContentTypeId(contentType);
   taskList.ContentTypesEnabled = true;
                SPContentTypeId matchContentTypeId = taskList.ContentTypes.BestMatch(contentTypeId);
                if (matchContentTypeId.Parent.CompareTo(contentTypeId) != 0)
                {
                    SPContentType ct = taskList.ParentWeb.AvailableContentTypes[contentTypeId];
                    taskList.ContentTypes.Add(ct);
                    taskList.Update();
                }
            }
            catch
            {
                throw;
            }
        }
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker