1

Is there a way to apply rules in a specific order?

I want to offer YesNo ONLY if two specific values are selected from another field... my rules in XML look like this:

  <WHEN field="xxx.yyy.FoundInVersion" value="xxx">
    <ALLOWEXISTINGVALUE />
    <ALLOWEDVALUES not="[project]\xxx" expanditems="true">
      <LISTITEM value="No" />
      <LISTITEM value="Yes" />
    </ALLOWEDVALUES>
  </WHEN>
  <WHEN field="xxx.yyy.FoundInVersion" value="yyy">
    <ALLOWEXISTINGVALUE />
    <ALLOWEDVALUES not="[project]\xxx" expanditems="true">
      <LISTITEM value="No" />
      <LISTITEM value="Yes" />
    </ALLOWEDVALUES>
  </WHEN>
  <ALLOWEDVALUES not="[project]\MigrationAccounts" expanditems="true">
    <LISTITEM value="No" />
  </ALLOWEDVALUES>

This works. If either of the both WHENs are correct Yes and No are allowed.

But TFS somehow automatically (on the different/target instance) moves the last ALLOWEDVALUES rule to the top, and only No is allowed and selectable, even if I select one of the values "yyy" or "xxx" in the other field.

It seems to cache somewhere, or try to be intelligent or sth.

How can I force/workaround the rules to my own order?

Ferdi Öztürk
  • 101
  • 1
  • 10

1 Answers1

1

Rules are typically processed in the sequence in which they are listed. However, when you use the WHEN*, DEFAULT, and COPY elements, additional behaviors may apply.

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 TFS performs and by the user of a work-item form. Only steps 1, 8, and 13 are performed by the user.

1.From a Team Foundation client─such as Visual Studio, Team Explorer, Team Web Access, or Team Explorer Everywhere─, a 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.

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

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62