共用方式為


Use templates to add and update work items in Azure Boards and Visual Studio

TFS 2017 | TFS 2015 | TFS 2013

Visual Studio 2019 | Visual Studio 2017 | Visual Studio 2015

With work item templates, you can quickly create work items that have pre-populated values for your team's commonly used fields. For example, create a template that defines the area path, iteration path, and activity to use when creating a task.

You can use work item templates to create work items or bulk update several work items. For examples that show usage of work item templates, see Sample work item templates.

Note

Work item templates are distinct from process templates. For information on process templates, see Choose a process template or these specific topics for the default process templates: Basic, Agile, Scrum, or CMMI.

Supported template tasks

The availability of template task options depends on the client and platform version available to you. Add and manage work item templates from the web portal or from Visual Studio 2015 or earlier versions. Visual Studio 2015 and earlier versions support working with templates by installing the Microsoft Visual Studio Team Foundation Server 2015 Power Tools. These templates only appear in your view of Team Explorer.

As shown in the following table, a ✔️ indicates the task is available from the web portal or from Visual Studio 2015 or earlier versions. (Make sure that you've selected the content version based on your platform version).


Task

Web portal

Visual Studio 2015


✔️

✔️


Manage work item templates
(Define, edit, delete, copy link, create copy, and rename)

✔️

✔️


✔️

✔️


✔️

✔️


✔️

✔️


✔️

✔️


✔️


Tip

The templates you define through the web portal are distinct from those you define through Visual Studio. Web portal templates can only be managed and applied to work items through the web portal. Similarly, Visual Studio templates can only be managed, viewed, and applied to work items in Visual Studio. However, you can use the URLs of both template types to add work items through the web portal.

Prerequisites

Capture a work item as a template

The steps to capture a work item differ based on the platform, version, and client you use.

If you connect to an on-premises TFS and primarily create work items working in the web portal, you can create a hyperlink that captures the default values you specify for a template. Choose the hyperlink, and it opens the template in the web portal.

  1. From the web portal Queries page, open a new work item.

    Open a new work item from the web portal Work page

  2. Fill in the default values you want the template to specify. You can leave required fields empty, or place some text in them

    Here, we fill in several values, including tags, but leave the Title blank. When you're done, copy the URL for the template.

    Define fields and choose Copy the URL

  3. The URL defines each predefined field, for example (line breaks added for clarity):

    http://fabrikamprime:8080/tfs/DefaultCollection/Fabrikam%20Fiber/_workItems/create/Task?%5B
    System.AssignedTo%5D=Jamal+Hartnett&%5B
    System.Description%5D=%3Cp%3EAlways+include+Remaining+Work+and+links+to+any+related+bugs+or+user+stories.%3C%2Fp%3E&%5B
    System.Tags%5D=Web%3B+Phone%3B+Service&%5B
    Microsoft.VSTS.Common.Activity%5D=Development&%5B
    System.IterationPath%5D=Fabrikam+Fiber%5CIteration+1
    

    Tip

    The URL won't contain defaults defined for the work item type. To specify a default field value, see Add or modify a field. Also, there is a 2000 character limit imposed by some browser clients with no work around.

  4. Use the URL whenever you want to add a work item of the type you've defined with its predefined values.

    You can save the URL as a text file or add the URL to a dashboard or web page as a hyperlink.

Manage work item templates

You can view the list of templates defined for each work item type, and also add, edit, copy, delete, rename, and copy the link of a template. All templates are defined and managed for a team.

Manage templates for a work item type

Managing work item templates from the web portal is only supported from TFS 2017 and later versions.

Add a work item using a template

The main method for adding a work item using a template is to open the template link within a browser window. To get the template link, see the next section Copy the link to a template.

You can share these links through email, a network share, or a team dashboard.

Use the URL whenever you want to add a work item of the type you've defined with its predefined values. Copy the link to a shared network or send to your team via email. Also, consider adding a link to the team dashboard.

Managing work item templates from the web portal is only supported from TFS 2017 and later versions.

Apply a template to new or existing work item(s)

You can apply a template to a single work item or do a bulk update of several work items.

Apply a template to several work items

The feature to apply a template to existing work items from the web portal isn't supported for TFS 2015 and earlier versions.

You can specify a work item template that specifies several field values using the following syntax. Use the URL whenever you want to add a work item of the type you've defined with its predefined values.

http://{ServerName}:8080/tfs/DefaultCollection/{ProjectName}/_workItems/create/{WorkItemType}?
[FieldReferenceName 1]={FieldValue 1}&
[FieldReferenceName 2]={FieldValue 2}&
[FieldReferenceName 3]={FieldValue 3}&
. . .

For example, the following syntax specifies a work item task with title TaskTitle. It specifies values for the Assigned To, Description, Tags, Activity, and Iteration Path fields.

http://{ServerName}:8080/tfs/DefaultCollection/{ProjectName}/_workItems/create/Task?
[System.AssignedTo]=Jamal+Hartnett&
[System.Description]=<p>Always+include+Remaining+Work+and+links+to+any+related+bugs+or+user+stories.</p>&
[System.Tags]=Web;+Phone;+Service&
[Microsoft.VSTS.Common.Activity]=Development&
[System.IterationPath]=Fabrikam+Fiber%5CIteration+1

Tip

There is a 2000 character limit imposed by some browser clients.

You can save the URL as a text file or add the URL to a dashboard or web page as a hyperlink.

You can add links to a Markdown widget that appear on your team dashboard in the web portal. These links open a work item with the template defined fields predefined.

Note

Multiple team dashboards and the Markdown widget are available for Azure Boards and TFS 2015.2 and later versions.

For example, the following widget contains links to three templates.

Markdown widget with links to templates

To learn more about the Markdown widget see Add Markdown to a dashboard, Markdown widgets.