Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
    
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 '11 at 16:15
add comment

3 Answers 3

I've managed to solve the issue.

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

share|improve this answer
add comment

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?

share|improve this answer
    
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 '10 at 15:42
add comment

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?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.