Create Custom Work Item control to list all the names in Assigned To dropdown.

by Donovan Brown 7. November 2009 15:22

Problem:

I need to create a custom control that shows the same list of users as the Assigned To drop down.

Solution:

Use the AllowedValues collection of the System.AssignedTo Field of the work item.

Code:

foreach(string user in ((WorkItem)WorkItemDataSource).Fields["System.AssignedTo"].AllowedValues)
   _myDropDownList.Items.Add(user);

Explanation:

I have read many post on how to get the list of users and many take a much more difficult path using IGroupSecurityService.  The AssignedTo field has already done all the hard work so why do it again?  Simply cast the WorkItemDataSource property of the IWorkItemControl interface implemented by your custom work item control to a WorkItem and use the AllowedValues collection of the AssignedTo field.

Tags: ,

Work

Comments (1) -

Vibration Noise
Vibration Noise United States
1/26/2010 6:21:03 PM #

Sharing exact details like this post helped a lot.

Problem..solution..code and explanation. Well doneSmile

About the author

My name is Donovan Brown and I am a process consultant for Imaginet with a background in application development.  I also run one of the Nation’s fastest growing online registration sites for motorsports events DLBRacing.com.  When I am not writing software I race cars for fun.  DLBRacing.com has given me the opportunity to combine my two passions writing software and racing cars.

AdSense

Month List

AdSense