FAQ #1: How do you display a field twice on the same WIT form?

Many times I get asked questions, either via forums, in person, email, whatever. Sometimes, I answer the question several times. What I'm going to start doing is posting FAQ entries on this blog as I encounter these questions. Hopefully, you'll find them useful.

One question I get is, how do you display a field more than once on the same form? The scenario I've heard described is that the form has multiple tabs, and they'd like to show the same field on multiple tabs. If you just specify the field name, WIT gives you an error.

Here's the work around:

In the form section of the WIT you see lots of <Control> elements.  An optional attribute of a <Control> element is Name – which in effect allows the WIT author to give each physical control a unique control name.  If it doesn’t exist then TFS will assign a default control name.  However if the same field is on the form multiple times, that default causes an error.  You can workaround the error by explicitly naming the control and giving each instance of the control a unique name. (See underlined portion in XML below)

<Control Name="DateStart2ndInstance" Type="FieldControl" FieldName="Microsoft.DeveloperDivision.Features.DateStart" Label="Date: Start" LabelPosition="Left" />