Share via


Add and Customize a Type of Work Item

You can add and customize types of work items for use with your specific team project. With each type of work item, you can add fields, states and transitions, and change the form layout. For each field defined for the type, you can add rules and define allowed values.

In this walkthrough, as you modify each component of the type, you import your changes into the team project and verify the changes by opening a new work item of that type.

Topic Contents

Perform the following procedures to add and customize a type of work item:

  1. Create a Team Project Named WITLab

  2. View the Work Item Form for the Task Type

  3. Export the Task Type

  4. Copy and Rename Task Type to Special Task Type

  5. Import the Special Task Type and Check Your Changes

  6. Add a New Field Named Category to the Special Task Type

  7. Add Rules to the Category Field

  8. Create a Pick List for the Category Field

  9. Change the Workflow for the Special Task Type

  10. Change the Form Layout for the Special Task Type

Prerequisites

To complete the steps in this walkthrough, the following conditions must be met:

  • You must have a copy of Visual Studio that has Team Explorer installed and have a connection to Team Foundation Server. For more information, see Connect to and Access Team Projects in Team Foundation Server.

  • If you can establish a connection to a Team Foundation Server and have the appropriate permissions set, you can make basic customizations to a work item type at a command prompt, batch file, or script file.

Required Permissions

To perform this procedure, you must be a member of the Team Foundation Administrators group or a member of the Project Administrators group for the project. For more information, see Team Foundation Server Permissions.

Create a Team Project Named WITLab

To create a team project

  1. Start Visual Studio.

  2. In Visual Studio, on the Tools menu, click Connect to Team Foundation Server.

    Note

    If you do not see this option, you have not installed Team Explorer. You must install Team Explorer before you will have the option to connect to Team Foundation Server.

  3. In the Connect to Team Project dialog box, select from the Team Foundation Server list a server that is running Team Foundation Server.

  4. In the Connect to Team Project dialog box, select from the Team Foundation Server list the server that contains the team project collection to which you want to add your team project.

    Note

    If the drop-down list is empty, click the Servers button to manually enter the server connection settings. Contact your Team Foundation administrator or team project administrator to obtain the connection settings.

  5. Click the name of the project collection to which you want to add your team project from the Directory list.

  6. Click Connect.

  7. On the File menu, click New Team Project.

    Note

    If you are not using the Project Management environment settings, then on the File menu, point to New, and then click Team Project.

    The New Team Project wizard appears.

    Note

    If you have not connected to a Team Foundation Server, you will be prompted to connect to one now. Review steps 2 through 6.

  8. On the Specify the Team Project Settings page, under What is the name of the team project?, type WITLab, and then click Next.

  9. On the Select a Process Template page, under Which process template should be used to create the team project?, click MSF for Agile Software Development - <version number>, and then click Finish.

    Creating the team project may take several minutes.

  10. When the Team Project Created page appears, clear the Launch the Process Guidance box, and then click Close.

    The new team project named "WITLab," appears as a node in Team Explorer.

View the Work Item Form for the Task Type

Prerequisites: You must have completed Create a Team Project Named WITLab. The "WITLab" team project appears in a node in Team Explorer.

To view a work item form

  1. Start Visual Studio and open Team Explorer.

  2. In Team Explorer, expand the WITLab team project, and wait several seconds for its folders to load.

  3. In the team project, right-click the Work Items node, point to Add Work Item, and then click Task.

    A form that represents a new Task work item appears. Some of its fields contain default values. Later in this topic you can customize the Task work item type from which this work item was created.

Export the Task Type

Prerequisite: You must have completed Create a Team Project Named WITLab. The "WITLab" team project appears in a node in Team Explorer.

To export a work item type

  1. Open a Visual Studio command prompt.

  2. At the command prompt, type the following command and then press ENTER:

    witadmin exportwitd /collection:http://ServerName:Port/VirtualDirectoryName/CollectionName /p:WITLab /n:Task /f:"File Path\task.xml"

    This exports the Task work item type from Team Foundation Server to the task.xml file to the folder that you specify for File Path. The following appears when the export operation finishes:

    Work item type export complete.

  3. (Optional) To view the XML definition for the Task work item type, type "File Path**\ task.xml"** at the command prompt and then press ENTER.

Copy and Rename Task Type to Special Task Type

Prerequisite: You must have completed the Export the Task Type procedure.

To copy and rename the type

  1. In Visual Studio, click File, and then click Open File.

    This displays the Open File dialog box.

  2. Under Look in, move to the location where you exported the file.

    If you are modifying a type of work item to customize a process template, move to the location where you downloaded the process template.

    Note

    If you are running Windows Vista you might not have permissions set to certain folders. If you try to export the work item type to a location where you do not have permissions set, the registry virtualization technology automatically redirects the exported file and saves it to the virtual store. To avoid this redirection, you can export the file to a location where you have permissions set. For more information about registry virtualization, see the Microsoft Web site: Registry Virtualization and Common file and registry virtualization issues in Windows Vista.

  3. Click the task.xml file and then click Open. When you are prompted about line endings, click No.

    This opens task.xml, the XML file that contains the definition for the Task work item type.

  4. Locate the following element in the XML file.

    <WORKITEMTYPE name="Task">
    
  5. Change the value of the name attribute to Special Task.

    <WORKITEMTYPE name="Special Task">
    
  6. Save your change to a new XML file. To do this, on the Visual Studio File menu, click Save task.xml As.

    The Save File As dialog box displays.

  7. For File name, type specialtask.xml, and then click Save.

Import the Special Task Type and Check Your Changes

Prerequisite: You must have completed the Copy and Rename the Task Type to Special Task Type procedure.

To import the new type

  1. Open a Visual Studio command prompt.

  2. Import the Special Task type into Team Foundation Server. To do this, at a Visual Studio command prompt, type the following command and then press ENTER:

    witadmin importwitd /collection:http://ServerName:Port/VirtualDirectoryName/CollectionName /p:WITLab /f:"File Path\specialtask.xml"

    This imports the Special Task type into the WitLab project on Team Foundation Server. The following appears when the import operation finishes:

    Work item type import complete.

  3. In Team Explorer, select your team project, and then on the View menu, click Refresh to download the latest updates from the server.

    These updates include the new Special Task type that you just imported. Wait several seconds until all the nodes are loaded. Nodes that are still loading display the word working.

  4. Create a Special Task work item. To do this, right-click the Work Items node, point to Add Work Item, and then click Special Task.

    This work item is created from the work item type that you changed and imported.

Add a New Field Named Category to the Special Task Type

Prerequisite: You must have completed the Copy and Rename the Task Type to Special Task Type procedure.

To add a field

  1. Open the file that contains the Special Task work item type definition. To do this, in Visual Studio, click the tab labeled SpecialTask.xml.

  2. Find the following section of the XML file:

    <FIELDS>
    
  3. To create a string field that is named Category and Help text for a tooltip, type FIELD and HELPTEXT elements, as in the following sample:

    <FIELDS>
    <FIELD name="Category" refname="MyCompany.MyProcess.Category" type="String">
        <HELPTEXT>Describes the category to which this special task belongs.</HELPTEXT>
    </FIELD>
    

    Note

    The Reference Name, or refname, is the programmatic name for the field. All other rules should refer to this refname. For more information, see Naming Conventions for Work Item Tracking Objects.

  4. Find the section of the XML file that describes the work item form.

    <FORM>
    
  5. Find the following lines in the <FORM> section:

    <Group Label="Classification">
      <Column PercentWidth="100">
        <Control Type="WorkItemClassificationControl" FieldName="System.AreaPath" Label="Area" LabelPosition="Left" />
        <Control Type="WorkItemClassificationControl" FieldName="System.IterationPath" Label="Iteration" LabelPosition="Left" />
      </Column>
    </Group>
    
  6. To insert a control to display the Category field, type the Control element with Type="FieldControl" following the control for System.IterationPath, as in the following sample:

    <Group Label="Classification">
      <Column PercentWidth="100">
        <Control Type="WorkItemClassificationControl" FieldName="System.AreaPath" Label="Area" LabelPosition="Left" />
        <Control Type="WorkItemClassificationControl" FieldName="System.IterationPath" Label="Iteration" LabelPosition="Left" />
        <Control Type="FieldControl" FieldName="MyCompany.MyProcess.Category" Label="Category" LabelPosition="Left" />
      </Column>
    </Group>
    
  7. On the File menu, click Save to save changes to the XML file.

  8. Import the changed Special Task type into Team Foundation Server. To do this, repeat the steps provided in the procedure: Import the Special Task Type and Check Your Changes.

    Notice the new Category field on the form. Move the mouse pointer over the label of the field to see the tool tip.

  9. Click Close to close the new Special Task. Click No when you are prompted to save the work item.

Add Rules to the Category Field

Prerequisite: You must have completed the Add a New Field Named Category procedure.

To add rules to a field

  1. Open the file that contains the Special Task work item type definition. To do this, in Visual Studio, click the tab labeled SpecialTask.xml.

  2. Find the <FIELDS> section of the XML file, and in it, the Category field.

  3. To make Category a required field, add the REQUIRED element, as in the following sample:

    <FIELD name="Category" refname="MyCompany.MyProcess.Category" type="String" reportable="dimension">
    <HELPTEXT>Describes the category to which this special task belongs.</HELPTEXT>
    <REQUIRED />
    </FIELD>
    
  4. On the File menu, click the Save to save changes to the XML file.

  5. Import the changed Special Task work item type into Team Foundation Server. To do this, repeat the steps provided in the procedure earlier in this topic: Import the Special Task Type and Check Your Changes. 

    witadmin importwitd /collection:http://ServerName:Port/VirtualDirectoryName/CollectionName /p:WITLab /f:"File Path\specialtask.xml"

    The Category field is now highlighted, indicating that it is required.

  6. Select the Title field on the Special Task work item and type "Sample Task."

  7. On the toolbar, click Save to save the work item.

    An error dialog box appears that states that the Category field cannot be empty. Click OK to close the dialog box.

  8. In the Category field on the Special Task work item, type A category.

  9. Click Save to save the work item.

    The option to save the work item is now available.

  10. Click Close to close the new Special Task.

Create a Pick List for the Category Field

Prerequisite: You must have completed the Add Rules to the Category Field procedure.

To create a pick list

  1. Open the file that contains the Special Task work item type definition. To do this, in Visual Studio, click the tab labeled SpecialTask.xml.

  2. Find the <FIELDS> section of the XML file, and in it, the Category field.

  3. To add a list of allowed values for the Category field, insert the ALLOWEDVALUES element and a LISTITEM child element for each allowed value.

    <FIELD name="Category" refname="MyCompany.MyProcess.Category" type="String" reportable="dimension">
    <HELPTEXT>Describes the category to which this special task belongs.</HELPTEXT>
    <REQUIRED />
    <ALLOWEDVALUES>
        <LISTITEM value="Process Management" />
        <LISTITEM value="Planning" />
        <LISTITEM value="Execution" />
        <LISTITEM value="Review" />
    </ALLOWEDVALUES>
    </FIELD>
    
  4. To make Category an optional field, delete the REQUIRED element listed above the ALLOWEDVALUES element.

    <FIELD name="Category" refname="MyCompany.MyProcess.Category" type="String" reportable="dimension">
    <HELPTEXT>Describes the category to which this special task belongs.</HELPTEXT>
    <REQUIRED />
    <ALLOWEDVALUES>
        <LISTITEM value="Process Management" />
        <LISTITEM value="Planning" />
        <LISTITEM value="Execution" />
        <LISTITEM value="Review" />
    </ALLOWEDVALUES>
    </FIELD>
    
  5. Click Save to save changes to the XML file.

  6. Import the changed Special Task work item type into Team Foundation Server. To do this, repeat the steps provided in the procedure earlier in this topic: Import the Special Task Type and Check Your Changes. 

  7. Create a Special Task work item. To do this, right-click the Work Items node, point to Add Work Item, and then click Special Task.

    This work item is created from the work item type that you changed and imported.

  8. Click the list box for the Category field.

    Notice that the field now supports only the values specified by the ALLOWEDVALUES rules.

    Note

    The allowed values in the drop-list always appear in alphabetical order regardless of the order of the LISTITEM elements in the XML file.

  9. Click Close to close the new Special Task. Click No when you are prompted to save the work item.

Change the Workflow for the Special Task Type

Prerequisite: You must have completed the Create a Pick List for the Category Field procedure.

To change the workflow

  1. Open the file that contains the Special Task work item type definition. To do this, in Visual Studio, click the tab labeled SpecialTask.xml.

  2. Find the definition of the work item type’s workflow, in the <WORKFLOW> section of the XML file, as shown in the following XML:

    <WORKFLOW>
      <STATES>
        <STATE value="Active">
          <FIELDS>
            <FIELD refname="Microsoft.VSTS.Common.ClosedDate">
              <EMPTY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ClosedBy">
    ...
    

    Notice that only two states are defined- Active and Closed. The transitions between these states are also defined, in addition to an opening transition from the null state that is used when the work item is created.

  3. To add an Unapproved state to the type definition, insert another STATE element above the active state.

    <WORKFLOW>
      <STATES>
        <STATE value="Unapproved">
        </STATE>
        <STATE value="Active">
          <FIELDS>
            <FIELD refname="Microsoft.VSTS.Common.ClosedDate">
              <EMPTY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ClosedBy">
    ...
    
  4. Create a transition between the null state and the unapproved state. To do this, find the section of the workflow definition for transitions. Then, insert a TRANSITION element for the unassigned state to the Unapproved state. Because of this change, all new work items of this type will start in the Unapproved state with the default reason of New.

    <TRANSITIONS>
      <TRANSITION from="" to="Unapproved">
        <REASONS>
          <DEFAULTREASON value="New" />
        </REASONS>
      </TRANSITION>
      <TRANSITION from="" to="Active">
        <REASONS>
          <DEFAULTREASON value="New" />
        </REASONS>
        <FIELDS>
          <FIELD refname="Microsoft.VSTS.Common.ActivatedBy">
            <COPY from="currentuser" />
          </FIELD>
          <FIELD refname="Microsoft.VSTS.Common.ActivatedDate">
            <COPY from="clock" />
          </FIELD>
          <FIELD refname="System.AssignedTo">
            <COPY from="currentuser" />
          </FIELD>
        </FIELDS>
      </TRANSITION>
    
  5. Delete the TRANSITION element for unassigned to Active and all its child elements, which appear in the following sample. Perform this step because there can only be one opening transition, and you will want to use an opening transition called "Ported," which you will define in the following step.

    <TRANSITIONS>
      <TRANSITION from="" to="Unapproved">
        <REASONS>
          <DEFAULTREASON value="New" />
        </REASONS>
      </TRANSITION>
      <TRANSITION from="" to="Active">
        <REASONS>
          <DEFAULTREASON value="New" />
        </REASONS>
        <FIELDS>
          <FIELD refname="Microsoft.VSTS.Common.ActivatedBy">
            <COPY from="currentuser" />
          </FIELD>
          <FIELD refname="Microsoft.VSTS.Common.ActivatedDate">
            <COPY from="clock" />
          </FIELD>
          <FIELD refname="System.AssignedTo">
            <COPY from="currentuser" />
          </FIELD>
        </FIELDS>
      </TRANSITION>
    
  6. Add a "Ported" reason for the opening transition by inserting a REASON element following the default reason. If you make this change, users can verify whether a work item is new or was ported from another tracking system.

    <TRANSITIONS>
      <TRANSITION from="" to="Unapproved">
        <REASONS>
          <DEFAULTREASON value="New" />
         <REASON value="Ported" />
        </REASONS>
      </TRANSITION>
    ...
    
  7. Insert the COPY rule in the following sample. This rule makes the name of the user who created the work item the default value of the Assigned To field, and this rule can be evaluated only during the opening transition.

    <TRANSITIONS>
      <TRANSITION from="" to="Unapproved">
        <REASONS>
          <DEFAULTREASON value="New" />
         <REASON value="Ported" />
        </REASONS>
        <FIELDS>
           <FIELD refname="System.AssignedTo">
             <COPY from="currentuser" />
           </FIELD>
        </FIELDS>
      </TRANSITION>
    ...
    

    Note

    Inserting this rule under other <TRANSITION> or <STATE> elements will scope the rule to other Transitions or States.

  8. To create a transition from the Unapproved state to the Active state, insert the TRANSITION element and its child elements, as in the following sample. Because of this change, when a Special Task is approved, it can undergo this transition.

    <TRANSITIONS>
      <TRANSITION from="" to="Unapproved">
        <REASONS>
          <DEFAULTREASON value="New" />
         <REASON value="Ported" />
        </REASONS>
        <FIELDS>
           <FIELD refname="System.AssignedTo">
             <COPY from="currentuser" />
           </FIELD>
        </FIELDS>
      </TRANSITION>
      <TRANSITION from="Unapproved" to="Active">
        <REASONS>
          <DEFAULTREASON value="Approved" />
        </REASONS>
      </TRANSITION>
      <TRANSITION from="Active" to="Closed">
        <REASONS>
          <DEFAULTREASON value="Completed" />
          <REASON value="Deferred" />
          <REASON value="Obsolete" />
          <REASON value="Cut" />
        </REASONS>
    ...
    
  9. Click Save to save changes to the XML file.

  10. Import the changed Special Task work item type into Team Foundation Server. To do this, repeat the steps provided in the procedure: Import the Special Task Type and Check Your Changes. 

    Notice that the initial State is now Unapproved and that the Reason defaults to New. Additionally, the Assigned To value defaults to your account name. Click the Reason field to see a list box that lists the reasons New and Ported.

  11. In the Title field, type a title, and then click Save to save the work item. Wait until the save operation finishes, as indicated by Item(s) Saved on the status bar.

  12. In the State field, select the Active value to approve the work item and transition it again. Notice that the Reason field defaults to Approved.

  13. Click Save to save this transition.

  14. Click Close to close the Special Task.

Change the Form Layout for the Special Task Type

Prerequisite: You must have completed the Change the Workflow for the Special Task Type procedure.

To change the form layout

  1. Open the file that contains the Special Task work item type definition. To do this, in Visual Studio, click the tab labeled SpecialTask.xml.

  2. Find the <TabGroup> section of the XML file. Notice that there are <Tab> elements for Links and File Attachments in which each <Tab>element contains a <Control> element that renders the respective control.

    <Tab Label="Links">
      <Control Type="LinksControl" />
    </Tab>
    <Tab Label="File Attachments">
      <Control Type="AttachmentsControl" />
    </Tab>
    
  3. Merge the two <Tab> elements into a single Links and Attachments <Tab> element that contains both controls by replacing the XML shown in the previous step with the new XML that follows.

    <Tab Label="Links and Attachments">
      <Control Type="LinksControl" Label="Links" LabelPosition="Top" />
      <Control Type="AttachmentsControl" Label="Attachments" LabelPosition="Top" />
    </Tab>
    
  4. Find the section of the <FORM>, <Layout> definition that describes the Classification and Status groups.

    <Group Label="Classification">
      <Column PercentWidth="100">
        <Control Type="WorkItemClassificationControl" FieldName="System.AreaPath" Label="Area" LabelPosition="Left" />
        <Control Type="WorkItemClassificationControl" FieldName="System.IterationPath" Label="Iteration" LabelPosition="Left" />
        <Control Type="FieldControl" FieldName="MyCompany.MyProcess.Category" Label="Category" LabelPosition="Left" />
      </Column>
    </Group>
    

    Note

    For best results, every Control or Group should display in a Column even if the Column spans the full width of the form. In turn, every Column should display in a Group even if the Group has no visible label or boundary.

  5. Select the CONTROL element lines in the following sample, and then on the Edit menu, click Copy to copy this content to the Clipboard for later use.

      <Column PercentWidth="70">
        <Group>
          <Column PercentWidth="100">
            <Group Label="Classification">
              <Column PercentWidth="100">
                <Control Type="WorkItemClassificationControl" FieldName="System.AreaPath" Label="Area" LabelPosition="Left" />
                <Control Type="WorkItemClassificationControl" FieldName="System.IterationPath" Label="Iteration" LabelPosition="Left" />
                <Control Type="FieldControl" FieldName="MyCompany.MyProcess.Category" Label="Category" LabelPosition="Left" />
              </Column>
            </Group>
    
  6. To remove the Classification group from its current position on the form, delete the following lines from the sample: from <Group Label="Classification"> to </Group>.

    <Layout>
      <Group>
        <Column PercentWidth="70">
          <Control Type="FieldControl" FieldName="System.Title" Label="&amp;Title:" LabelPosition="Left" />
        </Column>
        <Column PercentWidth="30">
          <Control Type="FieldControl" FieldName="Microsoft.VSTS.Common.Discipline" Label="&amp;Discipline:" LabelPosition="Left" />
        </Column>
      </Group>
      <Group Label="Classification">
        <Column PercentWidth="100">
          <Control Type="WorkItemClassificationControl" FieldName="System.AreaPath" Label="&amp;Area:" LabelPosition="Left" />
          <Control Type="WorkItemClassificationControl" FieldName="System.IterationPath" Label="&amp;Iteration:" LabelPosition="Left" />
          <Control Type="FieldControl" FieldName="MyCompany.MyProcess.Category" Label="Category" LabelPosition="Left" />
        </Column>
      </Group>
    
  7. In the <TabGroup> section, find the following lines that define the Details tab:

    <Tab Label="Details">
      <Group>
        <Column PercentWidth="50">
          <Group Label="General">
            <Column PercentWidth="100">
              <Control Type="FieldControl" FieldName="Microsoft.VSTS.Common.Issue" Label="Iss&amp;ue:" LabelPosition="Left" />
              <Control Type="FieldControl" FieldName="Microsoft.VSTS.Common.ExitCriteria" Label="E&amp;xit criteria:" LabelPosition="Left" />
              <Control Type="FieldControl" FieldName="Microsoft.VSTS.Build.IntegrationBuild" Label="Integration &amp;build:" LabelPosition="Left" />
            </Column>
          </Group>
        </Column>
        <Column PercentWidth="50">
          <Group Label="Schedule">
            <Column PercentWidth="100">
              <Control Type="FieldControl" FieldName="Microsoft.VSTS.Scheduling.RemainingWork" Label="Remaining &amp;work (hours):" LabelPosition="Left" />
              <Control Type="FieldControl" FieldName="Microsoft.VSTS.Scheduling.CompletedWork" Label="Com&amp;pleted work (hours):" LabelPosition="Left" />
            </Column>
          </Group>
        </Column>
      </Group>
    </Tab>
    
  8. To move these controls to the Details tab, paste the contents of your Clipboard after the <Tab Label="Details"> element.

    <Tab Label="Details">
      <Control Type="WorkItemClassificationControl" FieldName="System.AreaPath" Label="Area" LabelPosition="Left" />
      <Control Type="WorkItemClassificationControl" FieldName="System.IterationPath" Label="Iteration" LabelPosition="Left" />
      <Control Type="FieldControl" FieldName="MyCompany.MyProcess.Category" Label="Category" LabelPosition="Left" />
      <Group>
        <Column PercentWidth="50">
          <Group>
            <Column PercentWidth="100">
              <Control Type="FieldControl" FieldName="Microsoft.VSTS.Common.Issue" Label="Issue" LabelPosition="Left" />
    ...
    
  9. To create a grouping around the moved fields and to divide the fields into two columns, add the Group and Column elements, as in the following sample,:

    <Tab Label="Details">
      <Group Label="Classification">
        <Column PercentWidth="50">
          <Group>
            <Column PercentWidth="100">
              <Control Type="WorkItemClassificationControl" FieldName="System.AreaPath" Label="Area" LabelPosition="Left" />
              <Control Type="WorkItemClassificationControl" FieldName="System.IterationPath" Label="Iteration" LabelPosition="Left" />
            </Column>
          </Group>
        </Column>
        <Column PercentWidth="50">
          <Group>
            <Column PercentWidth="100">
              <Control Type="FieldControl" FieldName="MyCompany.MyProcess.Category" Label="Category" LabelPosition="Left" />
            </Column>
          </Group>
        </Column>
      </Group>
      <Group>
        <Column PercentWidth="50">
          <Group>
            <Column PercentWidth="100">
              <Control Type="FieldControl" FieldName="Microsoft.VSTS.Common.Issue" Label="Issue" LabelPosition="Left" />
    ...
    
  10. Click Save to save changes to the XML file.

  11. Import the changed Special Task work item type into Team Foundation Server. To do this, repeat the steps provided in the procedure: Import the Special Task Type and Check Your Changes. 

    Notice that the Classification group is no longer on the main form. Click the Links and Attachments tab and the Details tab to see the results of the changes that you made.

  12. Click Close to close the new Special Task. Click No when you are prompted to save the work item.

See Also

Concepts

Customizing Project Tracking Data, Forms, Workflow, and Other Objects