Configuring rules
A rule can either provide additional validation of a field’s value or alter the behavior of a field, such as hiding a field. Some rules allow you to compare the value of a field with another field, while others compare it to values defined in the rule itself. However, you can't use rules to change or override field dependencies.
Rules are available in Creation, Task, and Admin Views but not in Grid Views. In Task Views, you cannot add rules to fields in the Task View header. Controller fields used in rules must be in the view.
To define rules, go to the Design tab in the View Designer. Select a field and click New Rule in a field's property panel. Select a Rule Type and add conditions. The field type determines what rule types are available. A field can have multiple rule types.
To remove a rule, hover over the rule on the property panel. Click remove and then Done.
There are also Required, Editable, and Read Only rule types. These rule types are defined when you click New Rule. Use them to define whether a field is required, editable, or read only based on the value of another field in the view, called a controller field.
- If Required is displayed as a toggle, you can set it to True. In which case, the Required rule type is disabled. If you set it to False, you can define a Required rule type that determines whether the field is required.
- If Read Only is displayed as a toggle, you can set it to True. In which case, the Editable and Read Only rule types are disabled. If you set it to False, you can define Editable or Read Only rule types that determine whether the field is read only or editable.
| Design | JSON | Description |
|---|---|---|
|
Editable Read Only |
editable readOnly |
Makes a field editable or read-only based on the value of one or more other fields. |
|
Visible Hidden |
visible hidden |
Makes a field visible or hidden based on the value of one or more other fields. |
|
Required |
required |
Makes a field required based on the value of one or more other fields. In a view, the Save button is disabled until the field is given a value. |
|
Greater than Greater than or equal Less than Less than or equal Equal |
greater greaterEqual less lessEqual equal |
Validates that a field’s value is greater than, less than, or equal to the value of another field of the same type, or to a value provided in the rule definition. You can define these rules on integer, decimal, date, or currency fields. In a view, a red star is displayed next to the field and the Save button is disabled until the validation passes. The Equal rule can also validate that two text fields have the same value. Large long string fields are not supported. |
|
Minimum Length Maximum Length |
minLength maxLength |
Validates that the value of a text field has a minimum or maximum number of characters. In a view, the Save button is disabled until the validation passes. You can define these rules on string fields. |
| Pattern | pattern |
Validates that the value of a text field has a specified format, for example, nnn-nn-nnnn. In a view, the Save button is disabled until the validation passes. You can define this rules on string fields. Large long string fields are not supported in pattern rules. |
Defining Editable and Read Only rules
About this task
You can define Editable and Read Only rules on any field type.
When you open the property panel for a field, the field type and field definition determine whether the Required property is displayed.
The controller fields must be either enumeration or actor fields.
On the JSON tab, editable and read only rules are defined when type is set to editable or readOnly. Must also specify either a controllers or controllerName attribute. Specify one or more controllers as an array. Use the short-hand format controllerName rather than controllers to specify only a single controller for which ANY value will satisfy the rule’s criterion.
In the following steps, select Editable or Read Only in Rule Type.
Procedure
Defining Visible and Hidden rules
Before you begin
About this task
The Visible and Hidden rule can be defined on any field type and on inline guidance for sections. If a visible field dependency is already defined on a field, you cannot define additional rules of these types on that field in a Task or Creation View.
The controllers must be either enumeration or actor fields.
On the JSON tab, visible and hidden rules are defined when type is set to visible or hidden. You must specify either a controllers or controllerName attribute. For more information, see Defining Editable and Read Only rules.
In the following steps, select Visible or Hidden in Rule Type.
Procedure
Defining Required rules
About this task
The field is validated to make sure that it has a value any time a change is made to the field or one of its controller fields. If the field is required but is missing a value, a message is displayed on the field and the Save button is disabled.
This rule can be defined on any field type, except on relationship fields where the object type (objectTypeName in JSON) is set to SOXDocument.
If a required field dependency is already defined on a field, you cannot define additional rules of this type on that field in a Task or Creation View.
The controllers must be either enumeration or actor fields.
On the JSON tab, a required rule is defined when type is set to required. You must specify either a controllers or controllerName attribute. See Defining Editable and Read Only rules for more details.
In the following steps, select Required in Rule Type.
Procedure
Defining Greater than, Greater than or equal, Less than, Less than or equal, and Equal rules
About this task
Any time a change is made to the field that it is validated to make sure that it satisfies the condition. If the value is being compared to another field, it is validated any time that field’s value changes. If the condition is not satisfied, a message is displayed on the field and the Save button is disabled. The message explains how to provide a valid value.
These rule types can be set up on integer, decimal, date, and currency fields. When comparing two fields, both fields must be of the same type. If one of the fields has no value, the rule is not evaluated.
Text fields can also have an Equal rule, but only to compare against another text field. Large long string fields are not supported.
On the JSON tab, comparison rules are defined when type is set to greater, greaterEqual, less, lessEqual, or equal. A compareTo attribute must also be specified.
Procedure
Defining Minimum Length and Maximum Length rules
About this task
The field is validated to make sure that the length of the text value is valid any time a change is made to the field. If the condition is not satisfied, a message is displayed on the field and the Save button is disabled. The message states how many characters are allowed.
These rules can be set up only for text fields.
You can provide either the Minimum Length or Maximum Length rule type. You can apply both to define a range.
On the JSON tab, minimum and maximum rules are defined when type is set to minLength or maxLength. Specify compareTo as a number of characters within quotation marks.
Procedure
- In the View Designer, click the Design tab. The palette is displayed.
- Select the field that you want to add a rule to.
- In the property panel, click New Rule.
- In Rule Type, choose Minimum Length or Maximum Length.
- Enter the number of characters.
- Apply a Severity (optional). For information, see Controlling error severity on rules.
- Click Done.
Defining Pattern rules
About this task
The field is validated to make sure that the value has the correct format any time its value is changed. If the format is not correct, a message is displayed on the field and the Save button is disabled.
This rule can be set up only for text fields. Large long string fields are not supported in pattern rules.
On the JSON tab, a pattern rule is defined when type is set to pattern. Specify compareTo as a valid regular expression.
Procedure
- In the View Designer, click the Design tab. The palette is displayed.
- Select the field that you want to add a rule to.
- In the property panel, click New Rule.
- In Rule Type, choose Pattern.
-
In Pattern, enter a valid regular expression, for example,
^[0-9]{3}-[0-9]{2}-[0-9]{4}$. - Apply a Severity (optional). For information, see Controlling error severity on rules.
- Click Done.
Controlling error severity on rules
About this task
When users enter values that do not pass a field's validation rules, an error is issued and the object cannot be saved. However, if you apply the Severity property, warnings are issued rather than errors. When a warning is issued, an object can still be saved.
You can add a Severity property to any validation rule type (Greater Than, Greater than or equal, Less than , Less than or equal, and Equal). You can specify it to be an error, warning, or information. If a rule has no severity property, errors are issued.
For example, a warning can be issued if a date field is not within the next 90 days. If the severity property is omitted, an error is issued.
The text in the message is set by the system and cannot be customized.
Multiple warning messages can be displayed for a field. However, only one error message is displayed.
Conditions, for example, field dependencies and field attributes, always issue errors rather than warnings.
An information message behaves like a warning but is displayed with an information symbol. The error message text is the same whether it is a warning or an information.
On the JSON tab, specify severity as error, warning, or info.
Procedure
- In the View Designer, click the Design tab. The palette is displayed.
- Select the field that you want to add a rule to.
- In the property panel, click New Rule.
- In Rule Type, choose a rule type.
- In Severity, choose Error, Warning, or Info.
- Click Done.