Control State Rules

If a control on an interview screen has a control state rule, it signifies that the state of the control will change dynamically based on the value of some other control the screen. To understand how to evaluate these rules you should start by reading about dynamically displaying controls on a screen. One important thing to note is that the client application must evaluate all control state rules for input controls in order to determine the data contract for the screen. Failure to do so may allow the user to enter values which violate the contract and result in warnings being returned from Investigate actions.

For attribute input controls, a control state rule will always have three conditions, hide, read-only and optional, as shown below:

<control-state-rule default-state="[default state]">
    <hide>
        [hide expression]
    </hide>
    <read-only>
        [read-only expression]
    </read-only>
    <optional>
        [optional expression]
    </optional>
</control-state rule>

Note: Reference relationship controls will only have the hide, and read only conditions, while non-input controls will only have a hide condition.

Like all control state rules, the conditions must be evaluated in order, that is:

if [hide expression] is true
    the control's state is hidden
else if [read-only expression] is true
    the control's state is read-only
else if [optional expression] is true
    the control's state is optional
else
    the control's state is [default state]

Expressions themselves can be ConstantExpression or a ValueExpression. A constant expression signifies that the condition always evaluates to the specified result, regardless of the value of any control on the screen. A value expression is of the form:

Expression is true [ if | unless ] [ attribute ] [ equals | not equals | in | not in ] [ values ]

For example, the control setting on the interview screen:

Control-state hide-if example

becomes the expression:

Hide if the severity equals 0

and the control setting on the interview screen:

Control-state show-if example

becomes the expression:

hide unless this control should be visible is true

The complete control setting on the interview screen:

Control-state all control state rules

becomes the expression:

if the severity equals 0
    the control's state is hidden
else if the severity in 1 or 2
    the control's state is read-only
else if the severity not in 3 or 4
    the control's state is optional
else
    the control's state is mandatory

If the attribute "the severity" is initially unknown, the interview service will state that the state of the control is mandatory. However, if the client sets the value of the "the severity" to 2, in the response setting a value for the control will result in an InvalidValueChange warning since the state of the control is now read-only.