Field choice list hook example
Use Choice list hooks to build a list of choices for the user. When HCL Compass software calls a choice list hook, it provides an instance of the HookChoices class in the choices parameter. You use this object in your hook to add items to the list or to sort the existing list items. If you do not sort the items in the choice list, they appear in the order in which they were added to the list.
The following example builds a choice list whose contents are the names of various operating systems.
VBScript
Sub OS_type_ChoiceList(fieldname, choices)
' fieldname As String
' choices As Object
' entityDef = defect
choices.AddItem("Solaris")
choices.AddItem("Windows")
End Sub
Perl
sub OS_type_ChoiceList {
my($fieldname) = @_;
my @choices;
# $fieldname as string scalar
# @choices as string array
# entityDef is Defect
# use array operation to add items. Example:
# push(@choices, "red", "green");
push(@choices, "Solaris", "Windows");
return @choices;
}