Clase CreateTaskWithContentType

Define una actividad de flujo de trabajo que se usa para crear un elemento de tarea en una lista de tareas de Microsoft SharePoint Foundation 2010, con un tipo de contenido especificado SharePoint Foundation 2010.

Jerarquía de la herencia

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

Espacio de nombres:  Microsoft.SharePoint.WorkflowActions
Ensamblado:  Microsoft.SharePoint.WorkflowActions (en Microsoft.SharePoint.WorkflowActions.dll)

Sintaxis

'Declaración
<ToolboxBitmapAttribute(GetType(CreateTaskWithContentType), "Resources.CreateTaskWithContentType.bmp")> _
<ActivityToolboxDisplayAttribute("VSTTSharePointWorkflowTask", True)> _
Public NotInheritable Class CreateTaskWithContentType _
    Inherits CallExternalMethodActivity
'Uso
Dim instance As CreateTaskWithContentType
[ToolboxBitmapAttribute(typeof(CreateTaskWithContentType), "Resources.CreateTaskWithContentType.bmp")]
[ActivityToolboxDisplayAttribute("VSTTSharePointWorkflowTask", true)]
public sealed class CreateTaskWithContentType : CallExternalMethodActivity

Comentarios

Debe asegurarse de que los tipos de contenido están habilitados en la lista de tareas de SharePoint Foundation donde se crea la tarea de elementos de lista. Si no están habilitados en esta lista, la actividad producirá una excepción de referencia de una referencia null (Nothing en Visual Basic) .

Ejemplos

Icono de MVP

El siguiente ejemplo de código se ha contribuido por Robert Bogue, uno de los MVP SharePoint Foundation.

Llegar a conocer su SharePoint Foundation MVP en este sitio Web.

El siguiente ejemplo de código actualiza un tipo de contenido.

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;
            }
        }
Public Shared Sub VerifyModifyTaskList(ByVal taskList As SPList, ByVal contentType As String)
   Try
      Dim contentTypeId As New SPContentTypeId(contentType)
   taskList.ContentTypesEnabled = True
                Dim matchContentTypeId As SPContentTypeId = taskList.ContentTypes.BestMatch(contentTypeId)
                If matchContentTypeId.Parent.CompareTo(contentTypeId) <> 0 Then
                    Dim ct As SPContentType = taskList.ParentWeb.AvailableContentTypes(contentTypeId)
                    taskList.ContentTypes.Add(ct)
                    taskList.Update()
                End If
            Catch
                Throw
            End Try
End Sub

Seguridad para subprocesos

Los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para subprocesos. No se garantiza que los miembros de instancias sean seguros para los subprocesos.

Vea también

Referencia

Miembros CreateTaskWithContentType

Espacio de nombres Microsoft.SharePoint.WorkflowActions