Hook for creating a dependent list
About this task
The following example assumes that the values you want for the client operating system depend on the values that the user selects for the server operating system.
Procedure
- On the server_os field, create a Choice
List hook with the enumerated list of values set to Windows NT and UNIX:
- VBScript
choices.AddItem("NT") choices.AddItem("Unix")
- Perl
push(@choices,"NT","Unix");
return @choices; #Rational ClearQuest Designer provides this line of code
- VBScript
- To prevent your users from adding new members to the list, select the Limit to list check box.
- To clear the old value in client_os when
a new value is selected in server_os, add the following line to the
server_os Value Changed hook:
- VBScript
SetFieldValue "client_os", ""
- Perl
$entity->SetFieldValue("client_os", "");
- VBScript
- On the client_os field, create a Choice
List hook:
- VBScript
dim server_os_choice set server_os_choice = GetFieldValue("server_os") select case server_os_choice.GetValue() case "NT" choices.AddItem ("Win95") choices.AddItem ("NT") choices.AddItem ("Web") case "Unix" choices.AddItem ("Web") end select
- Perl
$server_os_choice = $entity->GetFieldValue("server_os"); $svalue = $server_os_choice->GetValue(); if ($svalue eq "NT") { push(@choices, "Win95","NT","Web"); } elsif ($svalue eq "Unix") { push(@choices,"CQWeb"); } return @choices; #Rational ClearQuest Designer provides this line of code
- VBScript
- In the properties for the client_os hook, select Recalculate Choice list, so that whenever the server_os field changes, the values are recalculated.
- Add the client_os and server_os fields to the form by using list box controls.
Parent topic: Field hook examples