-->

Embedding Text in TFS Description Field

2019-05-13 00:50发布

问题:

I have a TFS Question regarding the Description field. Currently the TFS Description field is an empty field in which users add any info. Is it possible to embed some type of text?

Example: When creating a new bug, TFS Description field is empty. Instead I want to have the following populated within the description field.

  1. Configuration and Logs
  2. Version and Environment
  3. Reproduction Steps
  4. Device/Environment
  5. Screenshots or related files (certificates, etc.) are attached

I assume it would be similar to using the Default Value tags only that it would be done when the bug is created.

Thank you

回答1:

I figured out the solution.

My current description field is a plain text field so I set the field with a default value of X. I did this in the initial transition to when creating the Bug Work Item.

Then, I exported the Work Item XML and searching for:

<FIELD refname="System.Description">

Right under it, I found the Default Value tag, it looked like this:

<DEFAULT from="value" value="1. Configuration and Logs 2. Version and Environment" />

I proceeded to add the xml breakline tag &#xD; to separate the lines. The new Default would look like this

<DEFAULT from="value" value="1. Configuration and Logs &#xD; 2. AW Version and Environment" />

Finally, I imported the modified Bug.xml and tested it. Now whenever I open a new bug, these lines will be visible in the Description field



回答2:

I have not been able to find any support for this on current releases of TFS (e.g. 2015), so I went ahead figured this out myself.

This information was tested and working on TFS 2015, I assume it should on 2013 as well, I just cannot test that.

To start and understand I'll clear couple things up.

  • The bug WIT steps to reproduce field is a html field.

  • XML forms have special markup for certain characters, that are in a string for example.

    & = &amp;
    < = &lt;
    > = &gt;
    " = &quot;
    ' = &apos;
    
  • Example for this would be to add string value of the word "Reproduction Steps" in bold. The bug WIT steps to reproduce field is HTML, so we'll add HTML markup using the special XML markup.

    <b>Reproduction Steps</b>
    

    Would look like this inside the bug.xml:

    &lt;b&gt; Reproduction Steps &lt;/b&gt;
    

Now putting this all together, you'll want to export the bug WIT so you can edit the bug.xml and import back to project when done.

Tools > Process Editor > Work Item Types > Export WIT

Then you'll find this line in the bug.xml

<FIELD name="Repro Steps" refname="Microsoft.VSTS.TCM.ReproSteps" type="HTML"/>

You'll edit this to make it look like what is below, to embed the text inside the steps to reproduce bug field.

      <FIELD name="Repro Steps" refname="Microsoft.VSTS.TCM.ReproSteps" type="HTML">
    <DEFAULT from="value" value="All the embedded html/xml text will go here" />
  </FIELD>

Final product with requested text from OP will look like this.

<FIELD name="Repro Steps" refname="Microsoft.VSTS.TCM.ReproSteps" type="HTML">
<DEFAULT from="value" value="&lt;b&gt; Configuration and Logs &lt;/b&gt; &lt;br/&gt;
        &lt;b&gt; Reproduction Steps&lt;/b&gt; &lt;br/&gt;
        &lt;b&gt; Device/Environment&lt;/b&gt; &lt;br/&gt;          
        &lt;b&gt; Screenshots or related files (certificates, etc.) are attached&lt;/b&gt; &lt;br/&gt;" />
 </FIELD>

Once you save that bug.xml, you'll want to go back into visual studio and import it.

Tools > Process Editor > Work Item Types > Import WIT