0
votes

I would like to get a list of all the states for a work item. I am making a UI that will enable users to see the state of all tasks in TFS for a specific project.

In order to do this i need to show a column for each of the possible states an item could be in.

Is there any way to get this information using the API? If not i guess i will try something like this: TFS API - is there a way to get a list of the transitions for a workitem type? which involves looking at the xml to get them.

Thanks, Kohan

1

1 Answers

2
votes

The link you mentioned is the way to go, if one want to list ALL possible states for a given Work Item type.

The API does not expose any sort of States list. And portions of the Work Item Rule Engine are written in native code and thus are out of reach, in case you considered to go down the reflection route.

The WorkItemType class (which would be the place to look at to find the transitions), when opened up in Reflector, shows a private field of type PSWorkItemTypeClass, which in turn is a wrapper to the native object exposed by the Rule Engine (and, as one can imagine, it's a black box).

On the other hand, if you want to populate your UI with all the states currently in use, another option to consider would be to query the relational warehouse.

Connect to the Tfs_Warehouse database and issue the following query:

SELECT 
    DISTINCT [System_State]
FROM 
    [Tfs_Warehouse].[dbo].[CurrentWorkItemView]
WHERE 
    [System_WorkItemType] = 'Task' AND
    [ProjectNodeName] = 'My-Team-Project'

Where My-Team-Project is your team project name.

Take into account that there is some delay between the transactional store (where TFS stores the real work items) and the relational data warehouse.