Skip to main content

Add, Edit and Delete validation expressions

Add, Edit, and Delete Validation Expressions

Add, Edit, and Delete Validation expressions are associated with the Advanced tab of the Table Properties. These expressions are used when Addition, Edition, and Deletion are allowed for the table control. To enable these options, the following properties must be set:

  • In the Add options group, Allow add is enabled (Yes) and Inline add is disabled (No).
  • In the Row options group, Allow edit is enabled (Yes) and Inline edit is disabled (No).
  • In the Delete options group, Allow delete is enabled (Yes).

Validation Expressions

Validation expressions are scripting expressions that evaluate the coherence of the information entered when adding or editing a record in the table.

  • For Add and Edit validations, the validations are executed in the Work Portal when end users add or edit a record in a pop-up window or click the Save button.
  • For Delete validations, the validation is executed when an end user tries to delete a record from the table.

If a validation expression fails, the record WILL NOT BE SAVED.

These validations are built in the context of the Collection entity. As the new record is filled in the context of the Collection, the validations retain this context. Thus, the XPath navigation will start from the Collection entity.

ControlsProperties17

Adding, Editing, and Deleting Validation Expressions

  • To add a validation expression, click on the Expression icon FormsComponents151. This will display the Expressions editor.
  • To delete a validation expression, click the trash can icon FormsComponents149.
  • To edit a validation expression, click on the Name of the expression or the Expression icon FormsComponents151.

Example

In a Purchase Request process, it is necessary to validate that every new product included has coherent information.

New records are added using an Add form, so we can use Validation expressions.

We will validate that the Total price of the product is equal to the Unit price times the Quantity requested. If not, an error message should be displayed.

Steps:

  1. Go to the Table's Advanced properties on the form. Enable the Add option and disable Inline Add. This ensures that the Add form and the Validation expression are displayed.

  2. Relate and Add Form.

  3. Create a new Validation expression by clicking on the Expression icon FormsComponents151. The Expression editor will display.

    ControlsProperties18

  4. Include the following code:

    // Validates if the Total price entered is the same as the Unit price times the Quantity entered.
    if(<Totalprice> != (<Unitprice> * <Quantity>)) {
    CHelper.ThrowValidationError("Total price must be Unit price times quantity");
    }