A very good practice in software is to work with roles instead of working with individuals.
I’ve often noticed in the Sharepoint newsgroups that assigning a workflow task to a group seems to be a popular question.
First off you cannot assign a Task to Active Directory groups, but only to Sharepoint groups !
Let start by using the HelloWorldSequential workflow sample provided with the Sharepoint sdk. Open up the project in Visual Studio 2008 and modify the Install.bat file to specify your site collection url (for the feature activation) : find the http://localhost string and replace it with your site collection url.
Double click on Workflow1.cs to display the workflow in the Visual Studio workflow Designer.
Double click on the createTask1 activity to get into the code editor.
In the associated code (the CreateTask function), replace the line taskProps.Assignee with code described in the red rectangle below.We assume our approvers must be part of a (custom) group called “MyApproverGroup” that we will create later.
- Create a new group, name it MyApproverGroup, add several users; give this group the Contribute permission.
- Rebuild your solution, and start Install.bat; make sure the feature is activated in the site collection features, create a custom list, associate the workflow with the list and start an instance of the workflow and check the task list : indeed, a task has been created by the workflow and assigned to the MyApproverGroup.
- Login as one of the group user :
- Go to the task list and change the view to “By My Groups”, the new task shows up :