Field Validators for Business Objects

A field-level validation rule is a constraint you can define on any custom field. The rule is used to evaluate the value of the corresponding field each time a new value is submitted.

A field-level rule is appropriate when the rule that is to be enforced depends only on the new value being set. At runtime your field validation rule is executed before the field’s value is saved.

The expression or script that defines the rule must return a boolean value. The value is saved if all the rules validating the field return true. If any of the rules returns false, the error message of the failed rule is displayed and the new value is not saved. For example, when a form has several fields, the values for all the fields must pass all the validation rules before any new values are saved.

To create a field validation rule for a business object:

  1. Select the business object for which you want to add the new rule.

  2. Select the Business Rules tab of the business object.

  3. Click the Field Validators tab.

    You see a list of all field validators that are defined for the business object.
    Description of bo-field-validators.png follows
    Description of the illustration bo-field-validators.png

  4. Click + New Field Validator and type a name to identify the rule, the field that the rule will validate and the error message that is displayed if validation fails. You can modify these later if you want.

  5. Click Create Field Validator in the dialog box to open the editor.

  6. Create your rule by typing in the editor and by using the values and functions in the palettes. Use the palettes to help you add field values and functions that you might use to create your rule.

    Click the arrow next to the function or value in the palette to insert it at your insert cursor in the editor. When you select a function in the palette a description of the function and example of how to use it are displayed in the palette. Any object functions that you created for the business object will be listed in the Functions palette.
    Description of bo-field-validator-edit.png follows
    Description of the illustration bo-field-validator-edit.png

    The Field Values palette contains the variables newValue and oldValue. Your script can use newValue to reference the new value that will be assigned if validation passes. To reference the existing field value, use oldValue.

    You can optionally override the default Groovy timeout specified in the Timeout Override field.

  7. Click the Field Validators tab again to apply your rule to the field and exit the editor.