Creating a dependent choice list

IBM® Rational® ClearQuest® allows you to specify that the values of one field (dependent field) depend upon the values of another field (parent field). This is accomplished by defining a Choice_List hook on the dependent field that sets its choice list based upon the value of the parent field.

In this example, you have two fields: Platform and Version. Platform is the parent field and has a constant (enumerated) choice list. Version is the dependent field which calculates the appropriate choice list based on the value of Platform.

Version's Choice list hook gets recalculated every time Platform changes because its Recalculate Choice List option is set.

Note that any field change triggers the hook to be rerun.

In general, Recalculate Choice List should only be set for fields which have a Choice List Hook defined, and should not be set on those that do not.

This Choice List Hook code determines the enumerated content of the choice list based upon the value of the parent field, Platform.

In the following examples:

VBScript

' Add field choices for platforms
Dim platform

platform = GetFieldValue("platform").GetValue ()

select case platform

   case "Windows 2000"

      choices.AddItem ("Professional")

      choices.AddItem ("Professional SP1")

      choices.AddItem ("Server")

      choices.AddItem ("Server SP1")

   case "Windows NT Server"

      choices.AddItem ("4.0")

      choices.AddItem ("4.0 SP6A")

   case "Windows 98"

      choices.AddItem ("Win98")

end select 

Perl

my $platform;

$platform = ($entity->GetFieldValue("platform"))->GetValue();

if ($platform eq "Windows NT Workstation") {

   push(@choices, "3.51", "4.0", "4.0 SP2", "4.0 SP3");

} else {

   if ($platform eq "Windows NT Server") {

               push(@choices, "4.0", "4.0 SP3");

   } else {

        if ($platform eq "Windows 95") {

               push(@choices, "Win95");

        } else {

               push(@choices, " ");

      }

 }

} 

Feedback