Assign sharepoint workflow task to multiple users/groups RRS feed

  • Question

  • Hello,


    I need to assign workflow task to multiple users or groups based on the user department in the active directory. I am trying to use the AssignedTo property of the SPWorkflowTaskProperty to achieve this but don't know how. I tried to put multiple user ids in the sting separated by ";", but this is not working.


    Any suggestions are appreciated.

    Wednesday, August 29, 2007 3:27 PM


  • Hi,


    Please see this Thread, which is related to you topic and solved by them,




    Cheers, Sanjiv Kumar Sanjiv Blog | LinkedIn
    • Marked as answer by Mike Walsh FIN Wednesday, March 30, 2011 8:59 AM
    Saturday, March 27, 2010 5:15 AM

All replies

  • Have you tried to modify site column's settings changing "Allow multiple selections" to yes?
    Thursday, August 30, 2007 8:40 AM
  • I need to clarify my question. I am developing a custom workflow for SharePoint in VS2005. In this workflow, I use SPWorkflowTaskProperties.AssignedTo to assign take to users on task created. Now I need to assign the task to multiple users/groups in AD and I want to know how to make the AssignedTo property take multiple users.


    The next step is to assign task to uses based on the Department value in AD. I need to assign task to all the users in the same department in the Active Directory. Please advice on how to achieve this.



    Thursday, August 30, 2007 3:09 PM

  • Well, first change column's settings as I've said on my previous post.

    Then you have two possibilities:
    1. Build an SPFieldUserValueCollection with your SPPrincipal objects and assign it to prop value
    2. With your SPPrincipal objects construct a string with the form obj1.ID;#obj1.Name;obj2.ID;#obj2.Name;... and use this string as prop value


    Friday, August 31, 2007 1:25 PM
  • Massimo,


    Thanks for your feedback, but I don't think the solution applies to my situation. I am having a workflow developed in VS2005 and deployed to a content type in sharepoint. The content type is parked on a list now. I need to assign workflow task to multiple users automatically from the workflow code, not manually from sharepoint interface. The users are decided by some business logic, not from any field value.


    I have tried to put the string "user_id1;#user_name1;user_id2;#user_name2;" as the value of SPWorkflowTaskProperties.AssignedTo, but it is not working. I also tried to assign a user collection to the AssignedTo, but AssignedTo only takes a string value.


    Please advice on how I can achieve this.






    Friday, August 31, 2007 3:19 PM
  • Hello,
    any news regarding this issue? I have the same problem and I can't find any solutions.

    Thursday, October 25, 2007 10:09 AM
  • Hi you can use the below method to convert the user in SPUser type



    private SPUser GetUserName(SPListItem item, SPField userField)




    string currentValue = item[userField.Title].ToString();

    SPFieldUser field = (SPFieldUser)userField;

    SPFieldUserValue fieldValue;

    SPFieldUserValueCollection colle=null;

    if (field.GetFieldValue(currentValue).GetType().Name.Equals("SPFieldUserValueCollection"))


    colle = (SPFieldUserValueCollection)field.GetFieldValue(currentValue);

    fieldValue = colle[0];




    fieldValue = (SPFieldUserValue)field.GetFieldValue(currentValue);


    return fieldValue.User;


    catch (Exception ex)


    return null;





    And then convert it into string to store it in the assignedto field.



    Saturday, October 27, 2007 8:40 AM


    In order to assign to a group in either (SP, Active Directory, Machine) given the group name in the AssignedTo property and it should work.




    Tuesday, October 30, 2007 11:03 AM
  • Yes one group name will work, just like one user id. But the problem is that the AssignedTo property cannot take more than one value (group or user). If I need to assign the task to multiple users or multiple groups or combination of users/groups, I couldn't find a way to do that. If the AssignedTo property can take a Collection instead of a String, or if we can keep adding user/group to the AssignedTo, that would solve my problem. Please advice if you have any suggestions regarding this.



    Tuesday, October 30, 2007 12:44 PM



    Did you find any way of doing this?



    Tuesday, November 6, 2007 11:28 PM



    I tried to do this. But did not work. I assign the property everything works fine. But the users do not show up in the assigned to field. The fields is defenetly multiple selection , as if I manually add a task , that works.


    Can you please help me with this ?



    Tuesday, November 6, 2007 11:46 PM
  • You can assign more than one user, the best thing to do would be to create a group with the users that need to be assigned to a particular task.


    The user allbeit a user or a group must be in the site collection.




    Sunday, November 18, 2007 11:31 PM
  • how to check which groups are assigned to workflow in the moss 2007 using Moss Gui


    Friday, January 11, 2008 5:39 PM
  • Well, I also need to assign task to multiple users or multiple groups. So, the problem now doesn't have solution?
    Anybody in Microsoft can come into and give the answer? I think assigning to multiple users and groups is very usual.

    Thursday, July 31, 2008 2:07 AM
  • Hello,
    I have a simmilar problem, I created a multiple selection user field in the task list and I want to assign users to that field from the workflow code.
    I have done several attempts without success. The users do not show in the field. The only this I can do is assign a single user to the list like taskproperties.ExtendedProperties[my field guid] = "domain\\user"

    I have tried several combinations with lists of users using id;#domain\\user;#id2;#domain\\user2 ... and with a SPFieldUserValueCollection

    Hope you can help,


    Tuesday, August 19, 2008 5:11 PM
  • Hi,
    Found solution. You can refer the ReplicatorContactSelector example in the OfficeServerSDK.

    Thursday, August 21, 2008 8:16 AM
  • Hi,


    Did you get any solution for above mentioned problem? I need to assign an individual task to multiple users through task from code in createTaskWithContentType method.

    Any help would be appreciated?



    Friday, November 14, 2008 9:06 AM

    I have the following requirement with MOSS 2007 state machine workflow:
    Programatically i want to assign workflow task to  multiple sharepoint groups (to AssignedTo property) of Task list. Assume that i have set the property "Allow multiple selection" = true.

    I want to achieve this using c#.Net code.

    For example:
    this.workflowProperties.AssignedTo="MOSSGroup1" + ";" + "MOSSGroup2";  // Like this i can assign a task to multiple sharepoint groups. Each group may have 10-15 users.

    Through UI it is possible (means it can be achievable using MOSS Object model), by mentioning Group1 (press Ctrl+K) automatically sharepoint picks the group from site groups.

    Please let me know how to achieve this using MOSS 2007 object model? After achieving i can use the filter that you have mentioned.

    Thanks in advance.

    with  regards,

    Wednesday, March 25, 2009 9:01 PM
  • Assigning one task to multiple users at once by modifying the "Assigned To" field and making it a multiple users will cause issues (by design) in the workflow.

    Its something I came across while building a custom workflow for one of my clients and it caused the workflow to freeze on OnTaskChanged activity (it was executing once only).

    I researched it (spent days looking into the issue with no answers) and ended up creating a new column called "Participants" to hold all the users and managed the logic internally in the WF.

    Again, changing the "AssignedTo" field to multiple users will cause unsupported issues in the workflow.

    You've been warned :)

    Dennis Alzoubi
    • Proposed as answer by Dennis Alzoubi Monday, August 31, 2009 7:16 PM
    • Unproposed as answer by Mike Walsh FIN Thursday, March 4, 2010 4:55 AM
    Wednesday, April 29, 2009 9:22 PM
  • Hi,

    If I look at the problem statement it looks simple Solution for that here it is..

    Assigning one task to multiple users at once by modifying the "Assigned To" field and and the users in it.


    now.. then Task Status is "In Progress" Wait for Task changed event when.

    When any user change the task then use "Modify By" column to check who has changed the task status to "Complete" and then Remove that user using

      string[] allusers=SPWorkflowTaskProperty.AssignedTo.split(';');

     check the allusers.count and add other user back again to SPWorkflowTaskProperty.AssignedTo  donot add the one who has modify the status

    then Reset the Status of the Task To "In Progress" untill the SPWorkflowTaskProperty.AssignedTo isnot getting blank.


    • Edited by sangati Thursday, May 14, 2009 4:50 PM seprator is changed
    Thursday, April 30, 2009 5:30 AM
  • Ha ha ha....i sweated with this problem. You cannot assign tasks to mulitple users end of story!!! to accomplish this you will have create a State Machine workflow..

    Thursday, April 30, 2009 4:51 PM
  • Hi,

    Yes it's true that we cannot assign a task to multiple users

    can you explain how it is possible in state machin workflow?

    One think we can do that create a custom column of type peopleandgroup and add the users using formula -->ID;#LoginName;#ID;#LoginName

    Thursday, May 21, 2009 4:18 PM
  • Hi,

    ReplicatorContactSelector can not be applciable to StateMachine WF.
    So If you are having a  requirement like SendBack to previous Approver/Initiator ReplicatorContactSelector will not work.

    Only the solution is dynamicallly create a SPGroup of users who are supposed to approve/reject the task and assign the task to this dynamic group.
    (create  a splist column -say -->-named --> "GroupToAssign" ) and store the dynamic group  name created in this list column.
    Once the WF completes, just  delete the  group, by calling 

     string groupName = objSPListItem["GroupToAssign"].ToString();


    This way we can  assign a  task to mulitple users/groups.


    Thursday, May 21, 2009 6:02 PM
  • Guys, just parse the groups prior to using the AssignedTo? Also, it shouldnt matter if the data is from.....

    * This workflow is a sample approval workflow. This workflow demonstrates how to use
    * a serial/parallel workflow, workflow modifications, history events, custom states.

    SharePoint Server 2007 SDK: Software Development Kit http://www.microsoft.com/downloads/details.aspx?FamilyId=6D94E307-67D9-41AC-B2D6-0074D6286FA9&displaylang=en


    //Use the built-in methods to parse out the people

    Contact[] contacts = Contact.ToContacts((

    this.initFormData["Reviewers"] as string), this.workflowProperties.Web);


    //Determine if we want to expand groups that were entered into the form.


    if ((this.initFormData["GroupTasks"] as string) == "false")



    //Expand the groups (recursively)


    bool reachedMaxCount = false;

    contacts = Contact.ExpandGroups(

    this.workflowProperties.Web, contacts,


    ApprovalWorkflowSample.MaxExpansionCount, out reachedMaxCount);

    Prepare the replicator data
                string contactNames = "";
                foreach (Contact contact in contacts)
                    contactNames += string.Format(" {0},", contact.DisplayName);
                    SPWorkflowTaskProperties taskProperties = new SPWorkflowTaskProperties();
                    taskProperties.AssignedTo = contact.LoginName;
                    taskProperties.Description = string.IsNullOrEmpty(this.initFormData["Description"] as string) ? "No instructions were provided." : this.initFormData["Description"] as string;
                    taskProperties.DueDate = dueDate;

    Have fun :

    Ivan Sanders http://linkedin.com/in/iasanders http://dimension-si.com/blog
    Saturday, May 23, 2009 4:29 PM
  • Hi,

     Assign Task to multiple use is not working. You can use workaround as creating new field of type people and group and add then you can add multiple user in it using formula "<ID>;#<LoginName>;#<ID>;#<LoginName>"
    Hop this help.

    Saturday, June 27, 2009 4:23 PM

  • Hi all,

    Has anyone received any Microsoft communication about this issue?

    I can't believe that it cannot be achieved... because it is possible to do it using the SharePoint web interface.

    Hey... MS team... please advice about the current thread.

    Thursday, July 23, 2009 2:18 PM
  • Are you trying to collect data from multiple people?

    It looks like several actions in a workflow can be assigned to multiple people, but not Collect Data from a User.

    You can collect data that is simply recorded and not listed in the metadata of a file by setting the Action to Assign a Form to a Group. When you name the action, you can also build the form in the same wizard.

    Using this, you can recreate the Collect Feedback workflow, but imbed it as a step in a custom workflow.

    Saturday, November 14, 2009 2:51 AM
  • Hey Mauricio,

    Have you tried injecting changes to your workflow.  Something like this should work:

            public SPWorkflowTaskProperties newTask_Properties = new SPWorkflowTaskProperties();

            private void codeActivity1_ExecuteCode(object sender, EventArgs e)
                // Create a new instance of InvokeWorkflowActivityes
                InvokeWorkflowActivity invokeNewWorkflow = new InvokeWorkflowActivity();

                // Create an instance of WorkflowChanges
                WorkflowChanges changes = new WorkflowChanges(this);
                // NewWorkflow type
                Type type = typeof(Workflow1);
                invokeNewWorkflow.Name = "NewWorkflow";
                invokeNewWorkflow.TargetWorkflow = type;

                // New activity used to push the new changes on to our workflow
                CompositeActivity multipleTasks = new CompositeActivity();
                multipleTasks.Name = "multiTasks";

                // Get the the users from the AD DL that you are working with.  Store these in a container of some sort.
                // Get the count for the number of user in the group
                for (int i = 0; i < [number of users in the DL]; i++)
                    // Create correlation token
                    CorrelationToken newToken = new CorrelationToken();
                    newToken.Name = "nextTaskToken" + i.ToString();
                    newToken.OwnerActivityName = "Workflow1";

                    // Create GUID
                    Guid newGUID = Guid.NewGuid();

                    // Create createTask activity
                    CreateTask newTask = new CreateTask();
                    // Set correlation token
                    newTask.CorrelationToken = newToken;
                    // Set GUID for the task
                    newTask.TaskId = newGUID;
                    // Set the Name for the newTask
                    newTask.Name = "addNewTask" + i.ToString();

                    // Set properties for the createTask Activity
                    newTask.TaskProperties = newTask_Properties;
                    newTask.TaskProperties.AssignedTo = "Domain\\User"; // Can be fetched from your container with users in it.
                    newTask.TaskProperties.Title = "Created task in the While loop";
                    newTask.TaskProperties.Description = "Tasks that can be created in a while loop activity";
                    newTask.TaskProperties.DueDate = DateTime.Now.AddDays(7);
                    newTask.TaskProperties.EmailBody = "Email Body";

                    // Create onTaskCreated activity
                    OnTaskCreated createMyTask = new OnTaskCreated();
                    // Set corelation token
                    createMyTask.CorrelationToken = newToken;
                    // Set GUID
                    createMyTask.TaskId = newGUID;
                    createMyTask.Name = "createNewTask" + i.ToString();

                    // Add the newly created activities to the new change control tree
                // Apply transient changes to instance.



    • Edited by BillSafcik Tuesday, December 15, 2009 9:08 PM code Correction
    • Proposed as answer by BillSafcik Tuesday, December 15, 2009 9:11 PM
    • Unproposed as answer by Mike Walsh FIN Thursday, March 4, 2010 4:59 AM
    Tuesday, December 15, 2009 9:06 PM
  • I have contacted MS regarding this matter and they said that "By Design", the workflow tasks list's "Assigned To" Field does not support multiple users, to make matters even worst, the method underneath the AssignedTo object in the TaskProperties will return null if you assign more than one user to it.

    Workarounds suggested:
    a. Create a composite control which inherits from SPField and the inner controls(PeoplePickerEditor) controls reads the value stored in its parents’ ‘Value’ or ‘Text’ property and displays it. The Parent control keeps the multi-user value in text form, on rendering it in edit.aspx page the ‘PeoplePickerControls’ displays the value. And on AllItem.aspx page we need to display the user name with hyperlinks.

    b. Create a custom field type with a custom field control which inherits from SPFieldUser, this would help in bypassing the SPFieldType.User type checking.

    c. Create timer job, runs every 5 minutes, it does the job of querying the ‘Task’ library items for ‘Participants’ field with a null value. Once you have the items, you can call AlertTask function to update the task item.

    d. Create an activity within your workflow CAG(ConditionalActivityGroup) with a delay activity. This delay activity invokes every 5 minutes throughout the lifecycle of the workflow instance, as soon as it finds that task item has got a null value, it updates the ‘Participants’ field.

    The participants field they are talking about here is a custom field that I suggested to hold the multiple users that are assigned to the task. Hope this helps.
    Dennis Alzoubi
    • Edited by Dennis Alzoubi Tuesday, December 15, 2009 9:37 PM Formatting was lost!
    Tuesday, December 15, 2009 9:35 PM
  • Im not sure I understand what you saying. I have included code below straight from the SDK that allows for mutiple people with multiple tasks. Also, the SharePoint workflow service APIs provides both methods and event handlers. Methods will perform actions, and handlers will put the workflow to sleep and wake up on events. For example, using the CreateTask service method will create a task and register the workflow for events on that task. Using the OnTaskChanged service event handler mapped to that task will dehydrate the workflow while it’s waiting and rehydrate the workflow when the task is changed. I luv those words like dhydrate, i think ill grab a coke...


    1)    When running workflows reach a point in the code, a.k.a. schedule, where they need to wait for something to happen (such as a task edit), they are serialized (i.e. turned into binary) and

    a.     SharePoint workflows are document-centric, meaning they run process around a document or list item, and

    b.     They are human-based, meaning that they can drive people process by assigning tasks, in addition to automated computational process.

      /// <summary>
            /// Initializes the workflow. We parse the data from the form xml string using the 
            /// Form and Contact classes in the Microsoft.Office.Workflow.Utility namespace
            /// </summary>
            private void OnWorkflowActivated(object sender, ExternalDataEventArgs e)
                //Convert the initiation form data to a hashtable
                this.initFormData = Form.XmlToHashtable(this.workflowProperties.InitiationData);
                //Get the originator of the workflow
                this.workflowOriginator = Contact.FromPrincipal(this.workflowProperties.OriginatorUser);
                this.workflowName = this.workflowProperties.Workflow.ParentAssociation.Name;
                this.itemDisplayName = this.workflowProperties.Item.DisplayName;
                //Set the replicator execution type
                this.replicatorExecutionType = this.initFormData["SerialParallelRadioButtons"].Equals("1") ?
                    ExecutionType.Sequence : ExecutionType.Parallel;
                //Add the data to the replicator so that we can generate a task for each contact.
                //The replicator will create a child for each item in the list.
                byte[] b = this.workflowProperties.Item.File.OpenBinary();
                using (MemoryStream ms = new MemoryStream(b))
                    SignatureLineHelper slp = new SignatureLineHelper();
                    this.signatureLines = slp.GetSigLines(ms);
                //Set the wss user id of the workflow originator
                int workflowOriginatorId = this.workflowOriginator.PrincipalID;
                //Setup the "workflow started" history data
                this.logWorkflowStartedHistoryActivity.HistoryDescription = string.Format("{0} has started.", this.workflowName);
                this.logWorkflowStartedHistoryActivity.UserId = workflowOriginatorId;
                //Setup the "workflow completed" history data
                this.logWorkflowCompletedHistoryActivity.HistoryDescription = string.Format("{0} was completed.", this.workflowName);
                this.logWorkflowCompletedHistoryActivity.HistoryOutcome = string.Format("{0} on {1} has successfully completed.", this.workflowName, this.itemDisplayName);
                this.logWorkflowCompletedHistoryActivity.UserId = workflowOriginatorId;
            /// <summary>
            /// Initializes and creates the tasks for each replicator child (a WssTaskActivity; 
            /// see Microsoft.Office.Samples.ECM.Activities sample for details)
            /// </summary>
            private void OnReplicatorChildInitialized(object sender, ReplicatorChildEventArgs e)
                //Retrieve the activities
                SignatureLine line = e.InstanceData as SignatureLine;
                WssTaskActivity task = e.Activity as WssTaskActivity;
                //Setup the task
                task.TaskId = Guid.NewGuid();
                task.createWssTask_TaskProperties1 = new SPWorkflowTaskProperties();
                task.createWssTask_TaskProperties1.Title = string.Format("Please sign {0}", this.itemDisplayName);
                //Set the description
                task.createWssTask_TaskProperties1.Description = "There is a signature line that you need to sign";
                //Set the remaining values
                task.createWssTask_TaskProperties1.PercentComplete = 0;
                task.createWssTask_TaskProperties1.SendEmailNotification = true;
                task.createWssTask_TaskProperties1.StartDate = DateTime.Now;
                task.createWssTask_TaskProperties1.TaskType = 0;
                task.createWssTask_TaskProperties1.ExtendedProperties["SigSpotId"] = "{" + line.ID.ToString().ToUpperInvariant() + "}";
                task.createWssTask_TaskProperties1.ExtendedProperties["BBarBtnTitle"] = "Sign";
                task.createWssTask_TaskProperties1.AssignedTo = this.workflowProperties.Originator;
                if (!String.IsNullOrEmpty(line.SuggestedSignerEmail))
                    //if the signature line has an email address
                    SPPrincipalInfo spi = SPUtility.ResolvePrincipal(this.workflowProperties.Web, line.SuggestedSignerEmail, SPPrincipalType.All, SPPrincipalSource.All, null, true);
                    if (spi != null)
                        //able to resolve the email address to a user
                        task.createWssTask_TaskProperties1.AssignedTo = spi.LoginName;
                //Set the "created by" user
                if (task.TaskCreatedBy == null)
                    task.TaskCreatedBy = this.workflowOriginator;
            /// <summary>
            /// Determines if the replicator is done yet.
            /// </summary>
            private void IsReplicatorDone(object sender, ConditionalEventArgs e)
                //Have all the replicator children completed?
                e.Result = this.taskReplicator1.AllChildrenComplete;

    Ivan Sanders My LinkedIn Profile, My Blog, @iasanders.
    Tuesday, December 15, 2009 10:34 PM
  • Hello Ivan,

    Have you tried the suggested code yourself? I can't get it to work for me. Maybe if you give more complete code and not only the methods things will be clearer. 

    Tuesday, February 9, 2010 9:59 PM
  • The replicator allows to assign a task to multiple users parallely or sequentially but it doesnt allows us to assign a task to multiple users at once and allow any one of them to complete the task. Is there a way to do that?

    Wednesday, March 3, 2010 10:41 PM
  • Hi,


    Please see this Thread, which is related to you topic and solved by them,




    Cheers, Sanjiv Kumar Sanjiv Blog | LinkedIn
    • Marked as answer by Mike Walsh FIN Wednesday, March 30, 2011 8:59 AM
    Saturday, March 27, 2010 5:15 AM
  • Hi Martin,

    Yes, but thats a simplified version and its where I started in 2006 SP07Beta2 with WF. Luckily I had the help of folks, where I could learn.. Recently, I have written event receivers that KO default WFs and pass the values to the WF. Either way the best place to start is with the SDK. parsing the groups and assigning each user a task is very doable, and I am not sure where the confusion is. However, it soulds like a good issue to blog on due to the number of responses this question has received. However, my next post is going to be on modification of the Web.Config file using SPWebConfigModification and how to insert child nodes, etc... This becomes more important in large farms...





    Ivan Sanders My LinkedIn Profile, My Blog, @iasanders.
    Saturday, April 3, 2010 6:32 AM
  • Just a thought, but why not create a secondary task list to store separate tasks for each user or group.

    Your custom workflow would create individual 'sub-tasks' in the secondary task list for each user or group, then create the main workflow task and wait for it to be completed. (You'd need to store a common ID value in the workflow task and 'sub-tasks' so they can be related).

    Then add a custom workflow to the secondary task list that, whenever a sub-task is complete, looks-up the related 'master' workflow task, marks it complete so the workflow continues, and deletes the other related sub-tasks. 




    Thursday, May 6, 2010 3:56 PM