I'm working on a SharePoint 2010 workflow which will assign multiple tasks to a list of users.
I'm using the Multiple Tasks webcast from Scot Hillier as a guideline http://www.shillier.com/archive/2010/08/04/Creating_Multiple_and_Parallel_Tasks%20_in_SharePoint_2010_Workflow.aspx, but I cant' get the workflow to work.
I've created the custom activity to create a single task, and used a replicator to start the this custom activity for every user. However, the sub-activities in my custom activity are not shown(as opposed to webcast).
public class CreateSingleTaskActivity : SequenceActivity
{
public Guid SPTaskId = default(Guid);
public string SPTaskOutcome = default(String);
public SPWorkflowTaskProperties SPTaskProperties = new SPWorkflowTaskProperties();
public SPWorkflowTaskProperties SPAfterProperties = new SPWorkflowTaskProperties();
public SPWorkflowTaskProperties SPBeforeProperties = new SPWorkflowTaskProperties();
public Guid TaskStatusFieldId = new Guid("FCA4FCB5-503C-4e9f-AC62-CD79EBCAAD67");
private OnTaskChanged onTaskChanged;
private CompleteTask completeTask;
private WhileActivity whileActivity;
private CreateTask createTask;
private bool complete;
private void createTask_MethodInvoking(object sender, EventArgs e)
{
SPTaskId = Guid.NewGuid();
SPTaskProperties.Title = TaskTitle;
SPTaskProperties.Description = TaskDescription;
SPTaskProperties.AssignedTo = TaskAssignedTo;
SPTaskProperties.PercentComplete = 0;
SPTaskProperties.StartDate = DateTime.Today;
SPTaskProperties.DueDate = TaskDueDate;
}
public sealed partial class EndUserReviewWorkflow : SequentialWorkflowActivity
{
private TaskData initTaskData;
public Guid workflowId = default(System.Guid);
public IList assignees = default(IList);
public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
public EndUserReviewWorkflow()
{
InitializeComponent();
}
private void onWorkflowActivated_Invoked(object sender, ExternalDataEventArgs e)
{
workflowId = workflowProperties.WorkflowId;
}
private void ReplicatorActivityInitialized(object sender, EventArgs e)
{
initTaskData = WorkflowHelper.DeserializeTaskData(workflowProperties.InitiationData);
string userList = initTaskData.AssignedTo;
string[] users = userList.Split(',');
assignees = users.ToArray();
createSingleTaskActivity2.TaskAssignedTo = assignees[assignees.Count - 1].ToString();
createSingleTaskActivity2.TaskTitle = initTaskData.Title;
createSingleTaskActivity2.TaskDescription = initTaskData.Description;
createSingleTaskActivity2.TaskDueDate = initTaskData.DueDate;
}
private void ReplicatorActivityChildInitialized(object sender, ReplicatorChildEventArgs e)
{
createSingleTaskActivity2.TaskAssignedTo = Convert.ToString(e.InstanceData);
createSingleTaskActivity2.TaskTitle = initTaskData.Title;
createSingleTaskActivity2.TaskDescription = initTaskData.Description;
createSingleTaskActivity2.TaskDueDate = initTaskData.DueDate;
}
Workflow is marked as Complete, although an 'System.Threading.ThreadAbortException' is thrown. No tasks were created. Can somebody try to figure out what I'm doing wrong?
Has anybody managed to assign multiple tasks in SharePoint 2010 and which source have you used?