Associate work item or code review to a changeset after check in

Open the Work Item, select "All Links", select the "Link To" button, then "Changeset".

Link To Dialog

You can then either enter the changeset number, or use "..." to browse.


To manually associate a changeset to a code review so that the code review shows up as a related work item in that changeset's details requires you to modify the work item form for the Code Review Request work item type. This requires the use of the TFS Process Template Editor.

TFS Versions supported

  • TFS 2015 | TFS 2013 | TFS 2012
    The steps below should be supported on these on premise deployments.
  • Azure DevOps Services (Hosted XML) | TFS 2018 | TFS 2017
    The work item form was redesigned in TFS 2017 and some of the XML used below was deprecated. If anyone can provide an equivalent definition for these newer versions I can update this answer.

Install Process Template Editor

Download and install the appropriate version of the Process Template Editor based on the version of Visual Studio that you have:

  • VS 2015: Microsoft Visual Studio Team Foundation Server 2015 Power Tools
  • VS 2017: TFS Process Template Editor
  • VS 2019: Process Template Editor

Modify the Code Review Request work item definition

Once the Process Template Editor is installed, follow these steps to update the Code Review Request work item form.

  1. Open the Code Review Request work item type definition from the server.
    1. Open Visual Studio and go to Tools > Process Editor > Work Items > Open WIT From Server.
    2. In the Connect to Team Project Collection dialog, select the appropriate collection and click Connect.
    3. Expand your team project, select Code Review Request and click OK.
  2. Add a new control for changeset links.
    1. In the Work Item Type window, click the Layout tab.
    2. Navigate to Layout > TabGroup > Tab Page - Links.
    3. Right-click Tab Page - Links and select New Control.
    4. Set the following properties:
      1. Type: LinksControl
      2. Label: Changeset
      3. Label Position: Top
      4. Name: ChangesetLink
    5. In the properties panel, find the Control Settings property and click the ... button to the right of "LinksControlOptionsType".
    6. If you see an error that says "Failed to load Control Settings" you should be able to safely dismiss it.
    7. On the XML tab, enter the following code and click OK:
      <LinksControlOptionsType>
      <LinkColumns>
          <LinkColumn RefName="System.Title" />
          <LinkColumn LinkAttribute="System.Links.Comment" />
      </LinkColumns>
      <WorkItemLinkFilters FilterType="excludeAll" />
      <ExternalLinkFilters FilterType="include">
          <Filter LinkType="Fixed in Changeset" />
      </ExternalLinkFilters>
      </LinksControlOptionsType>
      
  3. Update the server with your changes.
    1. Save the file. This will create one file with a .wit extension and one with a .xml extension.
    2. Go to Tools > Process Editor > Work Items > Import WIT.
    3. In the Connect to Team Project Collection dialog, select the appropriate collection and click Connect.
    4. In the Import Work Item Type Definition dialog, select the team project from the list.
    5. Click Browse..., select the .XML file, and click Open. Then click OK.

Adding the link

After updating the work item type definition, users may first need to click the refresh button in Team Explorer or in the browser the changes will be recognized.

Using Visual Studio

  1. Open the Code Review Request
    • Use Team > Go to Work Item..., OR
    • Enter the code review id in Team Explorer's Search Work Items field.
  2. Open the work item form by clicking Actions in the Team Explorer pane, and then click Open Work Item #
  3. Navigate to the Links tab, scroll down to the Changeset control, and click Link to.
  4. Enter the changeset id and click OK.

Using the TFS Web Interface

  1. Open the TFS web interface.
  2. Enter the code review id in the Search work items field.
  3. Navigate to the Links tab, scroll down to the Changeset control, and click Link to.
  4. Enter the changeset id and click OK.

Note that you can also conduct a code review on a checked-in changeset by going to the history right-clicking on the changeset and selecting

enter image description here

Tags:

Tfs