Share via


How Rules are Evaluated

You can gain some idea of how rules are evaluated when you apply multiple rules to a field. How rules are evaluated is not completely deterministic. This section describes the expected behavior and interactions when you are using the <WHEN*>, <DEFAULT>, and <COPY> rules.

The following steps show, in the correct sequence, the 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 the user.

  1. Using the Visual Studio user interface, the user creates a new work item or edits an existing work item.

  2. Fill in field defaults. For all fields, use any <DEFAULT> rules that are outside <WHEN*> rules.

  3. Copy field values. For all fields, use any <COPY> rules that are outside <WHEN*> clauses.

  4. For all fields with a <WHEN> rule that matches, first do <DEFAULT> and then <COPY> rules inside.

  5. For all fields with a <WHENNOT> rule that matches, first do <DEFAULT> and then <COPY> rules inside.

    Note

    The Team Foundation Server always processes <WHEN> rules before <WHENNOT> rules.

  6. 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.

  7. Allow the user to start editing.

  8. The user changes a field value and then moves focus from the field.

  9. Raise any <WHEN> rules for that field that match the new value.

  10. Raise any <WHENNOT> rules for that field that match the new value.

  11. Raise any <WHENCHANGED> rules for that field that match the new value.

  12. Return editing ability to the user.

  13. The user saves the changes to the database.

  14. For all fields, perform <SERVERDEFAULT> operations that are defined for the field either directly or indirectly under a <WHEN> or a <WHENNOT> rule.

Keystroke Processing

When a user uses the graphical user interface to modify a work-item form, a new value is set every time that 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, think carefully when you are using conditional rules.

<FIELD refname="MyCorp.SubStatus" />
<WHEN field="MyCorp.Status" value="Approve" >
<EMPTY />
</WHEN>
</FIELD>

See Also

Concepts

All FIELD XML Elements Reference

Assign Conditional-Based Values and Rules