Home > C#, TFS > TFS SDK: List the states transitions available for a WorkItemType

TFS SDK: List the states transitions available for a WorkItemType

Go to the TFS Content Page


When a WorkItem is in a specific state, only states that have transition from the current state are availalbe.

The following code access the WoirkItemType XML definition and extract all transitions defined. The list returned contains the from and to state transition available.

private static IList<Transition> LoadTransitions(WorkItemType workItemType)
{
   XmlDocument workItemTypeXml = workItemType.Export(false);
            
   XmlNodeList transitionsList = workItemTypeXml.GetElementsByTagName("TRANSITIONS");
   XmlNode transitionsNode = transitionsList[0];

   var transistions = new List<Transition>();
   foreach (XmlNode transition in transitionsNode)
      transistions.Add(new Transition(transition.Attributes["from"].Value, transition.Attributes["to"].Value));
   return transistions;
}
Categories: C#, TFS
  1. No comments yet.
  1. No trackbacks yet.

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

%d bloggers like this: