Example: Presenting a Dynamic Field List
This example demonstrates how you can present a different field list in a field, depending on the value of another field.
The user-defined function SW_SetLists_Environment
checks the value of the Environment Specification field and assigns the appropriate field list to the Environment Type field.
This example assumes that the field lists have been defined in the project. For details, see Customize field lists.
Note: To use workflow scripts to change or create lists that can be assigned to fields, you must use the Open Test Architecture (OTA) interface.
Add code to the Bug_MoveTo
event procedure so that the user-defined function SW_SetLists_Environment
is called when the user changes focus in the defects module.

Sub Bug_MoveTo()
On Error Resume Next
SW_SetLists_Environment
PrintError "Bug_MoveTo"
On Error GoTo 0
End Sub
Add code to the Bug_FieldChange
event procedure so that the user-defined function SW_SetLists_Environment
is called when a user changes the value of the Environment Type field in the Defects module.

Sub Bug_FieldChange(FieldName)
On Error Resume Next
If FieldName = "BG_USER_01" then
SW_SetLists_Environment
Else
' Enter your code here.
End If
PrintError "Bug_FieldChange"
On Error GoTo 0
End Sub
The user-defined function SW_SetLists_Environment
checks the value of the Environment Specification field (BG_USER_02) and assigns the appropriate field list to the Environment Type field (BG_USER_01).

Sub SW_SetLists_Environment()
Dim listName
On Error Resume Next
Select Case Bug_Fields("BG_USER_01").Value
Case "Browser"
listName = "Browsers"
Case "Database Type"
listName = "Database Type"
Case "Operating System"
listName = "Platform"
Case "Web Server"
listName = "Web Server"
Case Else
listName = "Environment Specification"
End Select
Bug_Fields("BG_USER_02").List = Lists(listName)
PrintError ("Set Environment List")
On Error GoTo 0
End Sub