Dynamic validation compares checklist answers to a value stored in the database for a unit. That means that the option value for this question must be stored in the database. Usually, those codes are received from an external system and stored in the unit_lookup_codes table.
To simulate that, the following code can be added to the bottom of the create_new_unit stored procedure of a database. All units will have the ‘STANDARD’ option stored.
-- Insert Unit Lookup Code
insert into unit_lookup_codes
(unit_id, lookup_code)
values
(@unitID, 'STANDARD')
This screen requires the stored procedure Create_New_Unit. If you do not have this stored procedure you will need to add it to your database. This can be done using this code in SQL
or Oracle
(seek technical assistance if required). This will create a stored procedure named Custom_Create_New_Unit. This name should then be used instead of Create_New_Unit.
A database lookup has to be created to look for the value:
1. Select Products > Checklist > Questions > Lookup Configurations.

2. Click Add.
3. Select Database Lookup as the Type and Validation as the Purpose, as shown below.

4. Click OK.
5. In the Tables List area, scroll to find the UNIT_LOOKUP_CODES table.
6. Drag the UNIT_LOOKUP table onto the TABLES item located in the Query Tree pane. This will display the list of available fields.

7. Select the LOOKUP_CODE field and click OK. You are returned to the SQL Builder dialog.
The FILTERS clause is used to determine which unit you want to check – in this example, it is the unit you have on screen and is identified by the [current_unit_id] run-time value.
8. Right-click on FILTERS and select Add.
9. Set the following values, as shown in the image below.
o Table: UNIT_LOOKUP_CODES
o Column: UNIT_ID
o Operator: EQUAL
o Filter: DYNAMIC, with current_unit_id selected from the list.

10. Click OK.
11. In the SQL Builder screen, enter a description for the database lookup and click OK to save.

12. Click Products > Checklist > Questions > Questions.
13. Highlight the checklist question and click the Edit button.
14. Select the Answers tab. Ensure that the static answers match the information you are checking for in the Validation tab.

15. Select the Validation tab.

16. Click Add to enter a new validation test.
17. Select Database Lookup and click OK.

18. In the Validation tab, select the recently created database lookup from the list and click OK.


19. You can now run Data Collect to answer the checklist question when it is presented and see how it validates the value entered in the unit lookup table.
20. The following image shows the example air filter checklist question with the correct option selected:

The following image shows the example air filter checklist question with the incorrect option selected:
