In this exercise, you will create a hook script and add it to the User_ID field that you previously added to the Defect record type. When you added the User_ID field, you defined its field type as Integer because users will enter a number in the field. Now you want to validate that users enter a number between 1 and 100.
To add a field hook:
Dim value_info
Set value_info = GetFieldValue (fieldname)
If Not IsNumeric(value_info.GetValue) Then
user_number_Validation = "Must be an integer between 1 and 100"
ElseIf (value_info.GetValue < 1) or
(value_info.GetValue > 100) Then
user_number_Validation = "Must be between 1 and 100"
End if
When a user enters a number in the User_ID field, the Rational ClearQuest client runs this validation hook script. If the user enters a nonnumeric value, or a number that is not in the range of 1 and 100, the hook script displays the appropriate error message.