Earlier this week at the Omaha Team System User Group someone asked about how to add new statuses to a work item in TFS. I mentioned I had the steps documented that I would send him. After reviewing the steps I thought it would be useful if I posted this for everyone.
Unless you prefer editing XML and running command line utilities to GUI editing, the first thing you should do is download the latest edition of TFS Power Tools. The Power Tools are a must have Team Foundation Server add-on that Microsoft has used to add functionality since the release of TFS Power Tools. There has been several updates with October 2008 being the latest release.
Download Visual Studio Team System 2008 Team Foundation Server Power Tools - October 2008 Release
After the TFS Power Tools are installed, Process Editor is now available under the Tools menu item.
To edit a Work Item Template (WIT) there are a couple options. To modify the template for one project, you can open the WIT directly from the project, edit it, and save it back to that project by choosing the “Open WIT from Server” option. When you choose “Open WIT from Server”, it will display a dialog with all of the team projects and the templates. In this example, the Bug WIT from the SampleScrum template is chosen.
To edit a WIT for multiple team projects, you will want to export the template to a file, edit the changes and then import that change into each of the team projects. To Export the WIT, choose Export WIT. This displays the dialog to select the WIT.
Save the WIT to a location on your local machine.
It will prompt you if you would like to include the Global List definition. You can choose No. Next open the saved WIT by choosing “Open WIT from File” and selecting the saved file (Bug.xml).
The Work Item Template Editor has three tabs. In this example we don’t change any of the fields or the layout of the work item, so we can ignore these tabs.
To add statuses to the Work Item, we will modify the Workflow tab. Adding a status is more than just adding the option to a list. The statuses of a work item are part of the workflow. Basically each status is only available when it is enabled in the workflow. For example, you might have a “Fixed” status and a “In Test” status. In the workflow, you can define it so that “In Test” won’t be available to select until it has been marked “Fixed” first.
Here is an example of the workflow tab
The different Statuses in Red and the arrows show the flow of one status to the next. Once it is decided when the new statuses will appear and what statuses will be available after the new status, we can add the statuses and connect them to the other statuses.
Add a Status by selecting the State item in the Toolbox (if the Toolbox is not visible, choose View -> Toolbox from the menu.
Drag the State item to the canvas in an area where it will be easier to connect it to the other States. If the workflow becomes cluttered, you can right click on it and choose “Reset Layout”
When you have added the status to the canvas it will look similar to this
Give the status a name by typing over the State1 text
Now, connect this to the previous status. For this example the bug will go from “In Progress” to “Fixed” to “Ready For Test”. Do this by clicking on the Transaction Link from the Toolbox, this will change your cursor to the link cursor. Click and hold on the starting Status and drag the line to the target Status. This will add the line between the two and create a Transition box.
For the new status to be valid, you must give the Transition a Reason. This is just a textual explanation why it would move to this status from the previous. Expand the Transition box so it shows the Reasons, Actions, and Fields. Right click on the box and choose “Open Details”. A Workflow Transition dialog box will display. Choose the Reasons tab and modify the Value to display the text you would like.
Add a second Transaction Link from the new status (Fixed) to the Target status (Ready for Retest) and give it a reason. Once this is added, you can validate your workflow by right clicking on the canvas and choosing “Validate All”.
If there are any errors in the validation they will be displayed in the Error List.
If there are no errors the Output tab will look similar to this
Click the save button in the toolbar to save the WIT. If you have opened the WIT from the server then this saves it back to the Team Project and is available. If this was a File then you must import it into the appropriate Team Project(s). To Import the Work Item Template, choose “Import WIT” from the menu. This dialog will display. Select the file that was edited (Bug.xml) and then select the team project and click OK.
Repeat to add to the other Team Projects.
Now that the work item is modified, if you want this change to be in new projects created you must update the source and re-upload the templates. Copy the bug.xml and bug.wit to the source template folder on the TFS Server. The Default location is C:\Program Files\Conchango\Scrum for Team System\ProcessTemplate\AgileSoftwareDevelopmentwithScrum\WorkItemTracking\TypeDefinitions
To upload the template, right click on the TFS root node in the Team Explorer and choose “Process Template Manager”.
A dialog will display that contains a list of the installed templates. Click on the Upload and browse to: C:\Program Files\Conchango\Scrum for Team System\ProcessTemplate\AgileSoftwareDevelopmentwithScrum Open the ProcessTemplate.xml file.
It will next prompt you if you want to overwrite. Choose Yes and it will upload the changes. If you do not wish to overwrite it, then you must change the name by opening the same ProcessTemplate.xml with the Process Editor.
That completes the steps to modify the Work Item Templates, apply the changes to one or multiple team projects, and also back to the template for future projects created with the the process template.
Mike
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.