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

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.

Comments (1) -

  • Sharing exact details like this post helped a lot.

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

Add comment

Loading