Scoping Field Rules by State, Transition, or Reason
As described in Defining Work Item Workflow, you can use field rules to determine work item type behavior regardless of the state of the work item. For example, a field that is required for a bug that is new and active remains required until the bug is closed.
Field rules can also be scoped to certain states, transitions, and even reasons. The complete set of rules that apply to any particular field is additive from four subsets:
Work item type-specific
State-specific
Transition-specific
Reason-specific
Work Item Type-Specific Rules
Work item type-wide rules apply regardless of the location of a work item in its state model. For example, a <REQUIRED/> rule makes the following check:
"MyField Value" != NULL
State-Specific Rules.
State-specific rules are scoped to a work item instance when it is in a certain state. Checking for a state-specific rule is as follows.
State field value == "MyState" && "MyField Value" != NULL
Transition-Specific Rules
Transition-specific rules are scoped to a work item that is undergoing a certain transition. Checking for a transition-specific rule is as follows.
State field value == "ToState" &&
"Previous State Before Edit/New" == "FromState"
&& "MyField Value" != NULL
Reason-Specific Rules
Reason-specific rules are scoped to a particular reason on a particular transition. Checking for reason-specific rules is as follows.
Reason field == "MyReason" &&
State field value == "ToState" &&
"Previous State Before Edit/New" == "FromState" && "MyField Value" != NULL
Scoping Field Rules
You can apply scope to field rules by using <FIELDS> and <FIELD> elements within the <STATE>, <TRANSITION>, and <REASON> elements.
Note
When you list fields in the workflow, specify only the field reference name.
Example
The following example defines the following rule: When a bug is in the active state, do not allow the customer severity field to be modified.
<STATE name="Active">
<FIELDS>
<FIELD refname="MyCorp.Severity" >
<READONLY />
</FIELD>
</FIELDS>
</STATE>
See Also
Other Resources
Change History
Date |
History |
Reason |
---|---|---|
June 2010 |
Corrected syntax format of an example. |
Content bug fix. |