CreateTaskWithContentType Class Home
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)
Syntax

'Usage

Dim instance As CreateTaskWithContentType

'Declaration

<ToolboxBitmapAttribute(GetType(CreateTaskWithContentType), "Resources.CreateTaskWithContentType.bmp")> _
<ActivityToolboxDisplayAttribute("VSTTSharePointWorkflowTask", True)> _
Public NotInheritable Class CreateTaskWithContentType _
    Inherits CallExternalMethodActivity
Remarks

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.

Examples

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)
{
   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;
            }
        }
Inheritance Hierarchy

System..::.Object
  System.Workflow.ComponentModel..::.DependencyObject
    System.Workflow.ComponentModel..::.Activity
      System.Workflow.Activities..::.CallExternalMethodActivity
        Microsoft.SharePoint.WorkflowActions..::.CreateTaskWithContentType
Thread Safety

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

Reference

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View