A Query Rule is used to validate the value of a field(s) through the output values of a query expression. A query expression is an SQL query that is used to fetch records from a database.
To apply this rule, the field(s) to which the query should apply need to be mentioned. This is followed by a Query expression for the field.
For example, if the Name field must be validated from a set of Names of Managers, a query can be run to extract the name of the Managers, which can be associated to the Name field through the query rule.
Executing the following query:
“select NAME from employee where DESIGNATION=’MANAGER’” would fetch out the names of the managers from a list of employees. The Name field can then be validated with this list of managers.
To configure a Query Rule within a module:
- Click on the Settings icon at top right corner on the Home page.
- From the left menu bar, select Modules.
- Select the module > Business Rules > Schema.
- Identify the desired schema and click on Detail > Add Business Rule.
- Under Rule Type, check Query Rule radio button.
- Click Next.
- Enter the name of the rule in Description.
- Select the preferred Category for the rule.
- In Fields, select the field(s) that need to be assigned the query rule.
- Write the Query Expression, the output values of which would be required to validate the field values.
- Write the desired Message in case the query expression validation fails.
- Select Finish.