Validation Rules

Prev Next

Validation rules helps you to manage correct data entry. If the validation occurs upon save and fails, a message is displayed. Validation rules are based on views and stored procedures in SQL that are registered as datasets and configured in the page’s Grid/Form.

During the design or modification of a WebApp, validation rules can be incorporated into a field based on an event.

Validation Rule Guidelines

  • Use the naming convention webXXX_YYYYVal where XXX is the primary table or page and YYYY describes what the validation rule is validating, for example, webOrderDetail_QtyGreaterThanOnHandVal.

  • Currently, you can run Validations only on the records of a page for which they are created. They are not connected or linked to additional pages.

  • Validation rules are assigned a Severity to dictate the status behavior. Severity types are:

    • Error - Marks the status as failed and fails until the error is corrected.

    • Warning - Displays a message and the status can be validated or invalidated by the user.

    • Info - The status is Success but a message is displayed to convey relevant information.

      Note

      When creating an event that will be called indirectly, do not use Warning validations. Use Error validations. Warnings are intended for user interaction. Validations running on events used as business rules are non-interactive. In these cases, validations are only used to stop the business rules of the event from running via Orchestrate Workflow (or, in the case of a 'Continue on Failure' set of rules, to allow the business rules to run).

  • If the validation rule is only relevant under certain data conditions provide a "Conditional Column" in the view to allow for a 0 (disabled) or 1 (enabled) value to determine whether the Validation rule executes. This can be useful when, for example, ensuring a field has a non-NULL value when another column is enabled.

View-Based Validations

Use the primary key fields on the underlying table as binding criteria for the validation view.

Note

Construct Preview requires explicitly listing out the binding criteria for the data record to the view to determine whether the validation is successful or not.

Stored Procedure-Based Validations

Use a Stored Procedure to implement additional validation rules that cannot be achieved using view-based validations.

Construct Preview processes stored procedure validations differently than Construct V1. Construct V1 required the procedure to RETURN a non-zero value to consider the validation as failed. Construct Preview requires a THROW statement in the procedure to return an non-zero MESSAGE value.

-- Sample statement that retrieves @TaxCode value for evaluation

IF @TaxCode = '' OR @TaxCode IS NULL
 THROW 99999,'Missing Tax Code',1
ELSE
 RETURN 0
END

Register a View-Based Validation Rule as Part of an Event

Note

The validation view must already exist in the database (configured as the datastore used by the WebApp) and can be registered as a Dataset in the Catalog module.

  1. On the Construct Preview’s home page, edit the required WebApp. The WebApp configuration page is displayed.

  2. Access Pages > Your Page > Grid or Form > Events in the Tree Navigation panel.

  3. If you want to create a new event, click Add Event. Refer to Register an Event for more information.

  4. Click an existing event child node and click More Options (…) > Add Validation View Task. The Details Pane is updated with the Validation View fields.

  5. Enter the fields/properties listed in the following table as required using either form-based UI or Advanced mode:

    Note

    Enter the required Binding Field Names and Dependent Tasks. Dependent Tasks can include different construct event tasks, either those configured in the same WebApp or those from different datasets.

    Property (Name: Type)

    Description

    Supported Values/Notes

    name: string
    required

    Name of the SQL view validation rule

    Enter the name of the validation view. maxLength: 128

    severity: string
    required

    Severity level of validation messages

    Must be one of: Error, Warning, Info
    * Error: Marks the status as failed and stops the event.
    * Warning: Marks the status as failed and displays a message. You can re-run this event task.
    * Info: Marks the status as Success but displays information.

    message: string
    required

    Message shown to users when validation fails

    Enter a comment within length constraints. maxLength: 2000

    binding_field_names: array of strings
    required

    Field names used to bind against the view to limit returned records

    Enter the field names. The field name in the view should match the field names in the data grid. maxLength: 128

    dependent_tasks: array of strings

    A list of task names that must be completed before running this task

    Enter the name of dependent tasks. maxLength: 128

  6. Click Save.

Register a Stored Procedure-Based Validation Rule as Part of an Event

Note

The stored procedure must already exist in the database (configured as the datastore used by the WebApp) and can be registered as a Dataset in the Catalog module.

  1. On the Construct Preview’s home page, edit the required WebApp. The WebApp configuration page is displayed.

  2. Access Pages > Your Page > Grid or Form > Events in the Tree Navigation panel.

  3. If you want to create a new event, click Add Event. Refer to Register an Event for more information.

  4. Click an existing event child node and click More Options (…) > Add Validation Stored Procedure Task. The Details Pane is updated with the Validation Stored Procedure fields.

  5. Enter the fields/properties listed in the following table as required using either form-based UI or Advanced mode:

    Note

    Enter the required Parameter Names and Dependent Tasks. Dependent Tasks can include different construct event tasks, either those configured in the same WebApp or those from different datasets.

    Property (Name: Type)

    Description

    Supported Values/Notes

    name: string
    required

    Name of the SQL stored procedure validation rule

    Enter the name of the validation stored procedure. maxLength: 128

    severity: string
    required

    Severity level of validation messages

    Must be one of: Error, Warning, Info
    * Error: Marks the status as failed and stops the event.
    * Warning: Marks the status as failed and displays a message. You can re-run this event task.
    * Info: Marks the status as Success but displays information.

    message: string
    required

    Message shown to users when validation fails

    Enter a comment within length constraints. maxLength: 2000

    parameter_names: array of strings
    required

    List of field names that the stored procedure expects

    Enter the field names. The field name in the view should match the field names in the data grid. maxLength: 128

    dependent_tasks: array of strings

    A list of task names that must be completed before running this task

    Enter the name of dependent tasks. maxLength: 128

  6. Click Save.

Related Articles