Workflow Task Replicator

A SharePoint 2010 custom workflow task content type.

This content type allows you to assign multiple people to a workflow task in a workflow.

When creating an instance of this content type on your task list, event handlers will create a number of sub tasks. The parent task will completed when all sub tasks have been completed.

Install the package and activate the "WorkflowTaskReplicator ContentType" web feature

Creating a task from a workflow

private void createTaskWithContentType1_MethodInvoking(object sender, EventArgs e)
    //Init tasks
    createTaskWithContentType1_TaskProperties1 = new SPWorkflowTaskProperties();
    createTaskWithContentType1_TaskId1 = Guid.NewGuid();
    createTaskWithContentType1_ContentTypeId1 = WorkflowTaskReplicator.Helper.WorkflowTaskReplicatorContentTypeId.ToString();

    //Init users
    SPUser userAdmin = workflowProperties.Web.EnsureUser("administrator");
    SPUser userTest01 = workflowProperties.Web.EnsureUser("test01");
    SPUser userTest02 = workflowProperties.Web.EnsureUser("test02");

    //Make sure the task replicator content type is installed
    if (!WorkflowTaskReplicator.Helper.IsWorkflowTaskReplicatorCTAttachedToList(workflowProperties.TaskList))

    //Set task metadata
        true, //All sub tasks must be completed
        new SPContentTypeId("0x0108"), //Sub task content type id
        new List<SPUser>() { userAdmin, userTest01, userTest02 }, //Assign to users
        new List<SPUser>() { userAdmin }, //Additional contributors
        new List<SPUser>() { userTest01 }, //Additional owners
        new List<SPUser>() { userTest02 }, //Additional readers
        new Dictionary<string, string> { { "Title", "Halloha!!" }, //Sub task meta data
                                            { "DueDate", SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now.AddDays(1)) } });

Resulting tasks after launching the workflow

3 sub tasks have been created. One sub task has been completed, causing the parent task be 33% completed.

Permissions have been set on the items according to the settings in the code (screenshot taken by System Admin).

Retrieving the task data in your workflow code

private void codeActivity1_ExecuteCode(object sender, EventArgs e)
    //Get sub task id's and check if they have been completed
    SPListItem taskItem = workflowProperties.TaskList.GetItemById(onTaskChanged1_AfterProperties1.TaskItemId);

    Dictionary<Guid, bool> results = WorkflowTaskReplicator.Helper.GetSubTasksInfo(taskItem);

Last edited Mar 12, 2013 at 1:07 PM by fvanonckelen, version 10