Tuesday, December 29, 2009

assign a task to multiple users in SharePoint 2007 workflow

In one of my recent projects we have to assign a task to group of users in sharepoint custom statemachine workflow.After some googling I found that 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.At last interacting with our MSFT consultant Avneesh Kaushik ( http://www.avneeshnagina.com/ ) internal MOSS experts, we have came to a conclusion that 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.
the steps are given below on how to execute this:
1 Create a splist column -say -->-"GroupToAssign"
2 Store the dynamic group name created in this list column.
3 Once the WF completes, just delete the group, by calling
string groupName = objSPListItem["GroupToAssign"].ToString();
oSPWeb.ParentWeb.SiteGroups.Remove(groupName);
This way we can assign a task to mulitple users/groups
Also remember to assign the Contribute permission to the members of this group :

This discussion can be found in the below thread:
http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/eaa3a47d-e274-47ae-9f81-f51ec5c91756
Hope anybody who is going to implement the same may find it helpful.

Happy programming!!!