Add, Edit and Delete Validation expressions are associated in the Advanced tab of the Table Properties. These expression can be associated if Addition (Add options), Edition (Edit Options) and Deletion (Delete option) are allowed for the control. This requires the following properties to 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), Inline edit is disabled (No).
•In the Delete options group, Allow delete is enabled (yes).
Validation expressions are scripting expressions that evaluate the coherence of the information entered when creating or editing a record of a Table.
Validations are executed in the Work Portal when end users add or edit a record in a pop-up window, or click on the Save button.
For the Delete validations, when an end user tries to delete a record of a table the Validation will be executed.
If a validation expression is thrown 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.
To include a Validation expression click on the Expression icon (). This will display the Expressions editor.
Delete a related validation by clicking the trash can icon ().
Edit a related validation by clicking on the Name of the expression or the Expression icon ().
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 included is the Unit price times the Quantity requested. If not an error message should be displayed.
1. On the from, go to the Table's Advanced properties.
Enable the Add option and disable Inline Add. This way the Add form and the Validation expression will be shown.
2. Relate and Add Form.
3. Create a new Validation expression by clicking on the Expression icon ().
The Expression editor will display.
4. Include the following code:
//Validates if the Total price entered is the same as the Unit price times the Quantity entered.
CHelper.ThrowValidationError("Total price must be Unit price times quantity")
5. In the Work Portal, a new record is added. This will display a new window where the new record information must be entered.
6. When the information is entered, and the end user clicks on Save, the Validation expression will be executed.
In the image below the error message will display.