Defining server side validations
Last updated
Last updated
DML operations can be performed on a datasource that is based on a database table. The platform automatically generates appropriate insert, update and delete statements based on the metadata of the datasource and the operations performed by the user through the UI.
Server-side validations are actions that are performed to validate the data prior to posting it to the database or after fetching it from the database. The server-side validation script, written in the Java programming language, is executed in the sequence you defined.
For example, if there are fields named start date and end date in the user interface, the user must not be allowed to enter a start date that is greater than the end date. Such validations are performed using server-side validation scripts.
To define a server-side validation, open the Server Side Validations tab.
3. Enter and select the required parameters.
Parameter | Description |
Seq | A sequence number that is used to execute the validation scripts in a defined order |
Name | A name for the validation script For example, Active Dates Validation |
Active | Indicates that the validation script is active and will be fired based on the defined conditions |
Before Insert | Indicates that the script is fired before inserting the row into the database. This is fired for each row and the row is available as a variable named ‘data’. You can use the get and set methods on the data to access the attribute values. For example, you can use data.get("startDate"); and data.set("startDate", new Date()); to fetch and update the date. General use cases: a. Validating user submitted information before inserting into the database b. Manipulating the data before inserting |
After Insert | Indicates that the validation script is fired after inserting the row into the database. The changes made to the data will not reflect in the database. General use cases: a. Send notification and/or email b. Invoke/update another dataSource |
Before Update | Indicates that the validation script is fired before updating the row |
After Update | Indicates that the validation script is fired after updating the row |
Before Delete | Indicates that the validation script is fired before deleting the row |
After Delete | Indicates that the validation script is fired after deleting the row |
Before Validate | Indicates that the validation script is fired before validating the row. Note: Validate operation is fired only when the UI field has the ‘Server Validate On Change’ property enabled. |
After Validate | Indicates that the validation script is fired after validating the row |
Before Import | Indicates that the validation script is fired before importing the row from an MS Excel sheet |
4. Enter your script in the script editor and click Save.
2. To add a validation script, in the upper right corner of the Validations pane, click. In the Validations pane, a row for displaying the script details is added. In the right pane, the options for defining a server side script are enabled.