STATE Element of the work type definition in Team Foundation Server
STATE Element is one of the most important elements that can be specified while creating work item type definition. It determines states of the work item throughout its life span.
Here is an example of the STATE element from bug work item type that comes with the default installation of TFS Agile Process Template.
<STATE value="Resolved">
<FIELDS>
<FIELD refname="Microsoft.VSTS.Common.ClosedDate"> <EMPTY/> </FIELD>
<FIELD refname="Microsoft.VSTS.Common.ClosedBy"> <EMPTY/> </FIELD>
<FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
<COPY from="field" field="System.Reason"/>
</FIELD>
</FIELDS>
</STATE>
We can see from the above listed XML code that our work item called bug has a state called “Resolved” and several system fields such as ClosedDate, ClosedBy and ResolvedReason.
We should be very careful when setting up elements. For instance, the following state element can cause unexpected errors. The problem with this is that ChangedBy field is editable field and validation may not handle errors properly.
<STATE value=" ">
<FIELDS>
<FIELD refname="System.ChangedBy">
<ALLOWEXISTINGVALUE />
<SERVERDEFAULT from="currentuser" />
</FIELD>
</FIELDS>
</STATE>
In addition, there are several important usages for the State element. State element can be used to define states. See example below for State definition within State element
<WORKFLOW>
<STATES>
<STATE value=" " />
<STATE value=" " />
</STATES>
</WORKFLOW>