Step by Step Tutorial.Creating workflows with Windows Sharepoint Services and MOSS 2007(Part 16/20). Assign a workflow task to a group of users

 

 

image

Introduction

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 !

 

Hands-on

 

  • 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.

image

  • 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.

image

 

  • Create a new group, name it MyApproverGroup, add several users; give this group the Contribute permission.

 

image

  • 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.

image

 

  • Login as one of the group user :

image

  • Go to the task list and change the view to “By My Groups”, the new task shows up :

image

Congratulations !

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s