Using the <WHEN*>, <DEFAULT>, and <COPY> Rules
This section describes the expected behavior and interactions when using the <DEFAULT>, <COPY>, and <WHEN*> rules. The following steps show, in proper sequence, interactions that are performed by Team Foundation Server and by the user of a work-item form. Only steps 1, 8, and 13 are performed by a user.
Using the Visual Studio user interface, a user takes action to create a new work item or edit an existing work item.
Fill in field defaults. For all fields, use any <DEFAULT> rules which are outside <WHEN*> rules.
Copy field values. For all fields, use any <COPY> rules which are outside <WHEN*> clauses.
For all fields with a <WHEN> rule that matches, first do <DEFAULT> and then <COPY> rules inside.
For all fields with a <WHENNOT> rule that matches, first do <DEFAULT> and then <COPY> rules inside.
The Team Foundation Server always process <WHEN> rules before <WHENNOT> rules.
For all fields that have had their values changed since step 1 and that contain <WHENCHANGED> rules, first do <DEFAULT> and then <COPY> rules inside.
Allow the user to start editing.
The user changes a field value and then moves focus from the field.
Raise any <WHEN> rules for that field that match the new value.
Raise any <WHENNOT> rules for that field that match the new value.
Raise any <WHENCHANGED> rules for that field that match the new value
Return editing ability to the user.
The user takes action to save the changes to the database.
For all fields, perform <SERVERDEFAULT> operations that are defined for the field either directly or indirectly under a <WHEN> or <WHENNOT> rule.
When a user uses the graphical user interface to edit a work-item form, a new value is set each time a keystroke is entered for a field. This means that a <WHEN* rule can occur unexpectedly whenever the rule’s prerequisite conditions are met.
In the following XML example, SubStatus will be emptied as you type "Approved Again" into the Status field because the <WHEN*> rule occurs as soon as the user types the letter "e" in Approved, even if the intended final value is not "Approve." For this reason, give careful consideration when using conditional rules.
<FIELD refname="MyCorp.SubStatus" /> <WHEN field="MyCorp.Status" value="Approve" > <EMPTY /> </WHEN> </FIELD>