Use validation rules to check if the data is in line with the defined standards.
To validate data, you can use several validation types. This topic explains how to set up a validation rule of type 'Query'. 

Use a query validation rule to validate if an entered field value is allowed using a dynamic query. Using a dynamic query, you can validate the field value based on one or more field values in another table. 

Examples of validations where you can apply a query validation rule:

  • On creating a sales order, check if address information or contact information is defined for the selected customer. If no address or contact information is defined, the customer cannot be used on a sales order.

  • On the worker setup, for the worker position, a cost center can be defined in the 'Cost center' financial dimension. Validate if the defined cost center is active. If not active, a warning or error message is given for the worker.

  • On terminating an employee, check if positions are reporting to the employee. If positions are still reporting to the employee, you cannot terminate the employee.

Before you can set up a query validation rule, set up the dynamic query to be used.

You can add validation rules in these ways:

  • Manually.
  • Select the fields to be validated from a page.


Standard procedure

1. Click Data quality management.
2. On the Data quality policies tab, in the list, click the link of the desired data quality policy.
 

Note: If you want to edit another data quality policy version than the currently shown version, first select the desired version. To do so, on the Action Pane, on the Version tab, click Versions. On the dialog, select the desired version and click OK.

3. Sub-task: Manually create validation rule.
  3.1 You can manually create a validation rule and define the table and field which value must be validated.
  On the Validation rules tab, click Add.
  3.2 Define the table of the field which value must be validated.
  In the Table field, enter or select a value.
 

Note: If you want to validate field values in inherited tables, define the child table instead of the base table. For example, instead of DirPartyTable, use DirOrganization or DirPerson.

  3.3 Define the field which value must be validated.
  In the Field field, enter or select a value.
4. Sub-task: Create validation rules by selecting fields.
  4.1 You can create validation rules by selecting the fields, which value must be validated, from a page.
  On the Validation rules tab, click Select fields.
  4.2 Open the page from which you want to select fields.
  4.3 On the Field picker dialog, click Select fields.
  4.4 Click the '+' button for each field that you want to select.
  4.5 On the Field picker dialog, click Done.
  4.6 On the Field picker dialog, click Submit to save the selected fields to the validation rule.
5.

Define to which records the validation rule is applied. You can apply a validation rule to:

  • New records only.
  • Existing records only.
  • New records and existing records.
  In the Record type field, select an option.
6. In the Validation type field, select 'Query'.
7. In the Event field, select 'Record validation'.
 

Note:

  • A query validation rule applies only to record validation.
  • The validation rule is applied just before the standard record validation is done.

8.

Define what is done if the validation rule is not met:

  • Warning: A warning message is shown. The record or the field value is saved.
  • Error: An error message is shown. The record or the field value is not saved.
  In the Outcome field, select an option.
 

Note: For each validation rule, you can define a message to be shown. If you do not define a validation rule message, in case of a warning or error, a default message is shown.

9. In the Dynamic query field, enter or select a value.
10. Usually, you use the current record as the range for the dynamic query.
  Select Yes in the Set current record in query field.
 

Note: If you do not use the current record as range, set the ranges manually.

11. Sub-task: Set the result fields.
  11.1 Specify which dynamic query fields are the result fields. Use a the result field to verify that the validated field contains a valid value.
  On the Properties tab, click Add.
  11.2 Select the Result check box.
  11.3 Select the result field from the dynamic query.
  In the Field field, enter or select a value.
 

Note: You can use fields from a table other than the validated field's table.

  11.4

Use a range expression to define the values that must be met during validation. For example, if the result field must have a value, the range expression is: !=""

To define a range expression, you can use:

  • A fixed value or a range of values using the advanced query syntax
  • A static method that defines the range. For example, you can use the SysQueryRangeUtil class to apply advanced date queries.
  In the Range expression field, type a value.
 

Note:

For more information on how to define ranges in the Range expression field, refer to Advanced filtering and query syntax.

12. Sub-task: Set query ranges and range values.
  12.1 You can use other ranges in the dynamic query than the current record.
  On the Properties tab, click Add.
 

Note: Only set ranges if the 'Set current record in query' field is set to 'No'.

  12.2 Define the ranges to be applied to the dynamic query.
  In the Field field, enter or select a value.
 

Note: To define a range, you can only use dynamic query fields that are set as range in the dynamic query setup.

  12.3

To set a range, you can use these types of values:

  • Field: Define a field which value is used as range in the dynamic query. The field value is taken from the validated record.
  • Fixed value: Define a fixed value that is used as range in the dynamic query.
  • Custom: Use a custom class and custom method to define a range.
  • Custom: Use a range expression to define a range.
  In the Value type field, select an option.
  12.4 In the Condition type field, select an option.
  12.5 If the Value type is Field, define the field which value is used as range in the dynamic query.
  In the Field name field, enter or select a value.
 

Note: Usually, you define the same field as the field that is used for the range.

  12.6 If the Value type is Fixed value, define the value that is used as range in the dynamic query.
  In the Fixed value field, enter or select a value.
  12.7 If the Value type is Custom, define the custom class with the method that you use to define a range.
  In the Class name field, enter or select a value.
 

Note: The custom class must extend the DQSCustomValidationBase class.

  12.8 If the Value type is Custom, define the method that you use to define a range. The method must exist in the defined custom class.
  In the Method name field, enter or select a value.
  12.9

If the value type is 'Range expression, define the range expression that is used to define the range for the dynamic query.

To define a range expression, you can use:

  • A fixed value or a range of values using the advanced query syntax
  • A static method that defines the range. For example, you can use the SysQueryRangeUtil class to apply advanced date queries.
  In the Range expression field, type a value.
 

Note:

For more information on how to define ranges in the Range expression field, refer to Advanced filtering and query syntax.

13. Close the page.

Provide feedback