Some of the workflow of the Work Items that come in the box in Team Foundation Server is second nature to us at Microsoft, but there are subtle issues which we take for granted that customers are starting to discover for the first time.

This week a customer contacted me because they were having trouble creating a query to show all bugs where "Assigned To = @Me" but didn't see all the bugs they were expecting. The intention was to see all bugs, regardless of state (Active, Resolved, or Closed) but none of the Closed bugs were showing up.

The reason for this is the workflow of bugs when they are closed - by default, the "assigned to" field is cleared when a bug transitions to the Closed state.

This is so that you don't see all the bugs that are now closed (and therefore considered 'done') in any queries for bugs assigned to you. If we didn't do this, then over time, you'd end up with a huge quantity of closed bugs all piling up assigned to you, so it would make simple queries like "assigned to @me" impossible.

If you take a look at the Closed state from the Work Item Definition XML you can see how this is implemented

<STATES>
    ....
    <STATE value="Closed">
    <FIELDS>
            <FIELD refname="System.AssignedTo">
                <EMPTY /> 
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ClosedBy">
                <REQUIRED /> 
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ClosedDate">
                <REQUIRED /> 
            </FIELD>
        </FIELDS>
    </STATE>
</STATES>

In the XML sample above you can see the changes and rules that automatically get applied to fields when the Work Item is put into the Closed state. In particular, the System.AssignedTo field is cleared by the use of the <EMPTY/> element - this is how the bugs become "unassigned" when they are closed, which was the source of confusion in this case.