0

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?

1
  • I am also working on the scott's article but my requirement is slightly different. a scenario to approve the document from multiple approver who belongs to various categories. For example IT Department - User1, User2, User3 Finance Department - User4, User5. The document will be approved when any of the user from each department approves the document. Say if User2 and User4 approved the document, the document is approved. But if only User4 and User5 approves we still need to wait from IT deparment to approve the document. Currently Document is in the approve status only when all the users appr
    – user5471
    Oct 31, 2011 at 16:15

3 Answers 3

2

I've managed to solve the issue.

Recreating the custom activity from scratch did the trick. It works like a charm now :)

0

Where are you making use of the assignees array list in your code? I see that you have just initialized but never used it. So not sure that e.InstanceData would containg any thing?

1
  • ReplicatorAcitivity.InitialChildData is bound to assignees in the designer. e.InstanceData does contain the desired user, and the ReplicatorActivityChildInitialized is called for every user in the list.
    – user1557
    Oct 1, 2010 at 15:42
-1

I use this post to creata multiple tasks but I cannot pass parameters to custom activity. I always get tasks without title, assignedTo....

Do I missing something?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.