Understanding record scripts

Record scripts are a generic form of hook that are called in response to an event on a HCL Compass form or from other hooks. Typically, record scripts are used to implement an action that you want to perform in response to a click event on a push button or on a context menu item associated with a particular field on a HCL Compass form. Record scripts are scripts that can be executed within the context of one record type.

If you associate a record script to a push button, when a user pushes the button, the script is executed.

All record scripts have the following syntax:

  • VBScript:
    
    Function RecordTypeName_ScriptName (param)
       ' input param As Variant
       'The content of the script...
    End Function
    
  • Perl:
    
    sub RecordTypeName_ScriptName {
       my($result);
       my($param) = @_;
       # The content of the script ...
       return $result;
    }
    

A record script:

  • Can be called upon in field hooks, action hooks and other record scripts of the same record type.
  • Is usually triggered by a form control to perform specific tasks at runtime.

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 for information on these events.)

When calling a record script from another hook, the parameter you pass into the method is a Variant containing whatever data is appropriate. If the record script returns data to the calling hook, that information is returned as a Variant as well.

You can associate one or more record scripts to a form control.