Record scripts

This topic explains the concept of Rational® ClearQuest® Web client record scripts.

Record scripts are a generic form of hook that are called in response to an event on a form or from other hooks. You can write a script that performs custom behavior in the context of a record. The scripts run in the context of the currently selected record. A record-script subroutine is specific to one record type.

Typically, record scripts are used to implement an action that is performed in response to a click event on a push button or on a context menu item that is associated with a particular field on a form. For example, a record script can send data about the current record to another system.

You can run a record script in three ways:

The following example shows the Visual Basic record script syntax:

 Function RecordName_HookName(param) 
   ' param As Variant 
   ' RecordName_HookName As Variant 
   ' ...
 End Function 
 

When calling a record script from another hook, the parameter you pass into the hook is a Variant that contains the appropriate data. If the hook returns information to the calling hook, return that information in a Variant.

When associated with a form control, the parameter passed into the method contains an instance of the EventObject class. This instance contains information about the event that caused the hook to be called. (See Form control events.) Rational ClearQuest software does not expect a return value from record scripts when they are associated with form controls. A non-null return value from a record hook is interpreted as an error and can be viewed in a message box by the Rational ClearQuest client.

Record scripts can be associated with push buttons, text fields, and lists. When associated with a button, clicking the button causes the hook to run. When associated with text fields and list-related controls, the hook is added to the context menu for the control.

You can also associate a record script with an action whose type is RECORD_SCRIPT_ALIAS. This association allows you to put a custom button on the Action menu of a Rational ClearQuest form.

For more information, see:

Using record scripts on Rational ClearQuest Web

Rational ClearQuest Web looks at the return value of a record script invoked by a push button. If the return value is a string, it is considered to be an error message and the hook fails.

If you do not explicitly set the return value of the record script function, it return a null or empty value that indicates that the hook ran successfully.

To enable record hooks for the Web, select Enable for web on the Extended tab of the control property sheet.

In Rational ClearQuest Web, record hooks run on the Rational ClearQuest Web server. For that reason, do not call Windows routines that cause a window to open; the window opens on the server instead of the client. The Rational ClearQuest Web Server sets a Session.NameValue object named CQ_WEB_SESSION when it starts a server session so that your scripts can be Web enabled.

Form control events

When a record script is triggered by a form control, Rational ClearQuest software passes the record script an EventObject object as its parameter. This object contains information about the type of event that occurred. Different controls can generate different types of events, including button clicks, item selections, and so on. You must use the information in the EventObject object to determine how to handle the event.

The following types of events are generated for form controls:

  • Button-click: Indicates that the user clicked a push button control.
  • Context menu item-selection: Indicates that the user ran the hook from a context menu.

The following table lists the supported event type for each control and the extra information provided by the EventObject. The constants listed under the supported event type column are part of the EventType enumerated type.

Control type Supported event type More information
Push button AD_BUTTON_CLICK Button name
Combo box AD_CONTEXMENU_ITEM_SELECTION Null string
Dropdown list box AD_CONTEXMENU_ITEM_SELECTION Null string
List box AD_CONTEXMENU_ITEM_SELECTION Current® field value selection
List view AD_CONTEXMENU_ITEM_SELECTION Current field value selection
Text box AD_CONTEXMENU_ITEM_SELECTION Current field value selection
Dropdown combo box AD_CONTEXMENU_ITEM_SELECTION Null string