Liath
Liath

Reputation: 10191

Specifying suggested values for a TFS Boolean Field

We're using a heavily customised set of TFS WorkItem Types for our development process.

One such type has a boolean field on it, however when we go to set this field you have to type in either "True" or "False", this is frustrating and I'd much rather have a checkbox or a set of suggested values we can pick from. Here's the field xml:

<FieldDefinition name="My Field" refname="My.BooleanField" type="Boolean">
  <SUGGESTEDVALUES expanditems="true">
    <LISTITEM value="True" />
    <LISTITEM value="False" />
  </SUGGESTEDVALUES>
</FieldDefinition>

However this doesn't work.

I was hoping I could change the control from a FieldControl to something more user friendly (like you can with DateTimes) but again I've had no success.

Is there a way I can create a boolean field on a TFS WorkItemType which doesn't require the user to type "True" or "False" or do I have to set it as a string to use Suggested Values?

Upvotes: 1

Views: 728

Answers (2)

KarmaEDV
KarmaEDV

Reputation: 1691

It only took 5 years and 3 major TFS versions, but the Checkbox control is finally part of the available Field Types!

With TFS 2015.2 you'll be able to chose the boolean type for a field.

The documentation does not include the change as of July '16 but this blog post confirms it.

Be aware that some important rules are not supported by this field type, such as "MATCH", "ALLOWEDVALUES" and "PROHIBITEDVALUES".

Upvotes: 1

jessehouwing
jessehouwing

Reputation: 114796

You could change <SUGGESTEDVALUES> to <ALLOWEDVALUES>. That tells the FieldControl to render a dropdown box:

 <ALLOWEDVALUES>
      <LISTITEM value="true" />
      <LISTITEM value="false" />
 </ALLOWEDVALUES>

That should make your life easier. Type Boolean is not an available field type, so you'll have to use string as the underlying data type. Check the field definition:

type="String | Integer | Double | DateTime | PlainText | HTML | History | TreePath | GUID" 

So you'll end up with:

<FieldDefinition name="My Field" refname="My.BooleanField" type="String">
  <ALLOWEDVALUES>
      <LISTITEM value="true" />
      <LISTITEM value="false" />
 </ALLOWEDVALUES>
</FieldDefinition>

A checkbox control is currently only available by deploying a custom control to the machine of all your users. There's a lot of demand for this feature, I'd expect Microsoft to support it in the future in in the form of the new Process Customization features that are available on Visual Studio Team Services.

Upvotes: 3

Related Questions