Working with Field Rules

Depending on the data type of a field, you can set various restrictions on what data can be entered into that field. For example, you can define a default value, restrict what values users can specify, and restrict who can update the value of the field. You may want to apply a rule to a work item field for one or more of the following reasons:

  • Specify the tooltip text that appears when a user hovers over a field in a work item form.

  • Require the value of a string field to match a pattern.

  • Make a field required or read-only, or make sure that it does not contain the same value as another field.

  • Clear a field, or restrict further modifications of a field.

  • Restrict who can modify the field.

  • Apply a rule to a field when the value of another field has changed or is assigned a specific value.

You can apply multiple rules to a field. If you include rules within a FIELD (Definition) element, the rules always apply. If you include them within the FIELD (Workflow) element, you can scope them to apply during a change in state, during a transition to a state, or when a user specifies a reason for a transition.

Common Tasks

Tasks

Related topics

Enforce rules always, during a transition, when a user changes the state, or when a user specifies a reason. You can use field rules to control the behavior of a type of work item regardless of its state. For example, a field that is required for a bug when it is new and active remains required until the bug is closed.

Apply rules that control the value of a work item field. You can restrict how the value of a field can change if you specify a qualifying rule, such as the CANNOTLOSEVALUE, EMPTY, FROZEN, NOTSAMEAS, READONLY, and REQUIRED elements.

Define the help text for a work item field. You can customize the help text or tooltip text that appears when a user points to a field that appears on a work item form. Help text is restricted to 255 Unicode characters and can be localized.

Restrict who can modify a field. You can restrict who can modify a field in a work item by using the VALIDUSER element.

Define the pattern that a string value must match. You can use the MATCH element to enforce a pattern on the contents of a string field.

Copy a value into a field. You can specify a default value for a field, or you can copy the value from another field or system-defined value. You can assign a field default by using one of the following elements: COPY, DEFAULT, and SERVERDEFAULT.

Use tokens for attributes that reference users or groups. When you restrict a rule to a user or group, you must indicate the domain or scope of the group. For some values, you can use tokens.

Limit a rule to apply or not apply to a specific group. You can qualify most rules to apply or not apply to a set of groups or users if you include the for or not attributes.

Specify conditions on field value assignments based on values in other fields. You can define rules that are run conditionally if you use the WHEN, WHENNOT, WHENCHANGED, and WHENNOTCHANGED elements.

Understand how rules are processed. 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.

See Also

Concepts

Designing the Workflow

All WITD XML Elements Reference

Other Resources

Defining Work Item Fields