Add a Rule to a Field

You can add a rule to a work item type field by exporting the XML file and modifying its content. As soon as you have added a rule to the work item type field, you can import the XML file to start to use the updated work item type.

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.

To add rules to a field

  1. If you are modifying a work item type on a single project, run witadmin exportwitd to export the XML file for the work item type you want to modify. For more information, see Customizing and Managing Work Item Types [witadmin].

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

    This displays the Open File dialog box.

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

    If you are modifying a work item type 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 access rights to certain folders. If you try to export the work item type to a location where you do not have access rights, 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 access rights. For more information about registry virtualization, see the following pages on the Microsoft Web site: Registry Virtualization and Common file and registry virtualization issues in Windows Vista.

  4. Select the work item type XML file that you want to update, and then click Open. When you are prompted about line endings, click No.

  5. Find the <FIELDS> section of the XML file and, in it, the field you want to modify.

  6. For this example, make a string field required by adding the following rule to the XML file. The rule is shown in bold text.

    <FIELD name="My Field" refname="MyCompany.MyProcess.MyField" type="String" reportable="dimension">
    <REQUIRED />
    </FIELD>
    
  7. On the File menu, click Save <file name>.xml to save changes to the XML file.

  8. To import the new work item type to a single project, see Customizing and Managing Work Item Types [witadmin]. To add the work item type to your process template, see Add a Work Item Type to a Process Template.

To verify changes imported to a single project

  1. In Team Explorer, click Refresh to download the latest updates from the server.

    These updates include the changes that you just imported. Wait several seconds until the Work Items node is loaded. Nodes that are still loading display the word working.

  2. Create a new work item by using your modified work item type. To do this, right-click the Work Items node, point to Add Work Item, and then click the work item type.

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

    Notice that the field you modified is now highlighted. This indicates that it is required.

  3. Select the Title field on the work item, and type Sample Work Item.

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

    An error dialog box is displayed that states that the field you modified cannot be empty. Click OK to close this dialog box.

  5. In the modified field on the work item, type My field.

  6. Click Save to save the work item.

    Notice that the work item can now be saved.

  7. Click Close to close the new work item.

See Also

Tasks

How to: Define a Rule Based on a Group

Other Resources

witimport

witexport

Work Item Type Definition Schema