Interesting rules to customize Work Items
1 – Customize Tfs Process Template
2 – Basic of TFS Process Template Customization
3 – Adding Field to a Work Item Definition
4 – Customize Work Item Fields with Rules
In fourth chapter we familiarized with Rules and how you can customize a Work Items adding rules to it. You can find a complete list of Rules at this link, but I want to show you the most useful ones (at least in my opinion).
Since you already know the ALLOWEDVALUES you should know the ALLOWEXISTINGVALUE a rule without parameter and is used to specify that we want to maintain a value even if it is not in the list of allowed values. This rule is useful if you change the list of available values (called PickingList) but you want to maintain old values, even if they are no more in the picking list. If you change the PickingList and you edit a work item that has an invalid value in a field, you are forced to specify a valid value to save again the element.
Another rule related to the PickingList is the PROHIBITEDVALUE that lists a series of values that are not allowed to be used in a field. As you see in Figure 1 the field is edited with a normal textbox, but if blabla is a prohibited value an error is shown.
Figure 1: Error value for a field that contains a prohibited value.
A third rule related to PickingList is the SUGGESTEDVALUES that contains a series of suggested values, but you can insert any value you want. When you apply this rules the editing field of the Work Item is a combo that contains all suggested values, but you can type any value you want.
The rule CANNOTLOSEVALUE states that a field once you set a valid value, could not be set to null anymore.
Another really interesting rule is called DEFAULT that permits to specify the default value of a field and it is really flexible.
Figure 2: Specify a value taken from another field as DEFAULT.
In Figure 2 I showed a very specific situation, I choosed * field in the from combo, this specify to TFS that I want to use the value of another field as DEFAULT for the field this rule is applied to. Then I choosed the System.ChangedBy field and saved the rule. Now I create another Bug based on this template, did not write anything in the new field (“Revision note) and simply press save to save the WI. Since the Revision Note contains the rule DEFAULT that states that the default value is taken from the field ChangedBy the value is updated accordingly as shown in Figure 3.
Figure 3: The content of Revision Note was automatically filled with DEFAULT value, taken from the ChangedBy
Clearly you can specify a constant for DEFAULT, you should choose valuefor the fieldcombo, and simply specify a constant value in the value textbox ( Figure 4 )
Figure 4: This is a classic default value, when the user creates another WI based on this template, the field contains this constant value.
You can use currentuserand clock as source of the default value.
Very similar to DEFAULT is the rule COPY , it is used to copy a value from a field to another during transition (I’ll speak about transition in subsequent posts).
Finally another useful rule is the MATCH , used to specify a pattern to check the validity of the content of the field..