TDOD Form: Populate field based on other field value

Document ID : KB000045864
Last Modified Date : 14/02/2018
Show Technical Document Details

Introduction: 

While using a form that is exposed through the Test Data on Demand (TDOD) portal, there is at times a requirement to populate a field value (or set of values) based on the value a user has selected for another field on the same form. This article explains how to implement such functionality.

 

Question: 

Is there a way to populate a TDOD field based on a value selected in the previous field? 

For example: If "Environment" field appears first in my form, and then comes "AGENT COUNTRY": 

If “QA1” is selected for the Environment field, how to display only certain values for “AGENT COUNTRY” based on the Environment value “QA1”? 

 

Environment:  

TDM 3.2.2 and later

 

Answer: 

Suppose the Datamaker variable for the "Environment" field, ~env~,  is defined as @aslist(@sqllist(P~DataSource~,SELECT XX from TABLE1)@)@.

This rule will provide a drop-down list of values for the "Environment" field - the values are determined by the results of the SELECT query.

 

You then need to define the variable used for the second field (AGENT COUNTRY in this case), based on the ~env~ variable. For example: 

@aslist(@sqllist(P~DataSource~,SELECT COUNTRY FROM table2 WHERE envcolumn IN ('~env~'))@)@

 

Additional Information:

More information on Datamaker functions and parameters can be found here: https://docops.ca.com/ca-test-data-manager/3-6/en/reference/datamaker-functions-and-parameters