When using variables in TDM, we do have the option to create a list to be used in a drop down for a variable.
A tester wants to clone data for a specific customer. The tester selects a customer from a drop down list for which to clone the data for.
If the tester knows the ID's of the customer, than it is just a matter of extracting the list of customer id's for a data source. But that isn't really user friendly and it does require that the tester does know the ID's of the customer.
The above scenario can be accomplished by using the following statement for the list definition of the variable:
@aslist(@sqllist(PnopcommercePROD,select id from customer where issystemaccount=0)@)@
A SQL query is used to retrieve the list of customer IDs.
The variable description will be used in the UI when the tester is requesting the data, therefor it is recommended to alter the description to a question or at least something more meaningful.
And now the more user friendly version of our customer ID selection.
For the list definition the following statement is used:
@aslist(@sqllist(PnopcommercePROD,select username,id from customer where issystemaccount=0)@,2,1)@
In this example the SQL query is retrieving a key/value list of the username and id of the customers. By adding ",2,1" to the aslist function we are actually saying use the first column to display the value and the second column as key. This result in a selection drop down using the customer username in the clone request as shown below.