Generating a custom message

The HCL Compass Client and the HCL Compass Web Client allow hooks to present error, warning, and information alert messages to users by embedding the alert message parameters within a normal hook error message. However, because the Compass for Windows™ client, user-written scripts, and older clients might not recognize the alert message parameters, this capability should be accessed through the global hook below, after adding it to your schema. If the client does not support custom messages, the hook uses the message parameters in a normal die statement. If the client does support custom messages, the hook uses the DieWithCustomMessage function.

The DieWithCustomMessage function below can be called from all places where a die statement can be used, and it will have the same effect as a die statement on the current operation. For example, calling the DieWithCustomMessage function from an access control hook would indicate failure in exactly the same way a die statement would indicate failure, but with a custom message.

Examples

Perl examples

sub Defect_generate_error_message {
  my($result);
  my($param) = @_;
  # record type name is Defect
  $error_summary="ReturnCustomErrorMessage";
  $error_details="Error message: Clicking this button will activate a computer virus!";
  # $result=&DieWithCustomMessage($error_summary,$error_details,"ERROR");
  DieWithCustomMessage("ERROR",$error_summary, $error_details);
  return $result;
}

sub Defect_generate_warning_message {
  my($result);
  my($param) = @_;
  # record type name is Defect
  $error_summary="ReturnCustomWarningMessage";
  $error_details="Warning message: Do not smoke at the work place!";
  DieWithCustomMessage("WARNING",$error_summary, $error_details);
  return $result;
}

sub Defect_generate_info_message {
  my($result);
  my($param) = @_;
  # record type name is Defect
  $error_summary="ReturnCustomInfoMessage";
  $error_details="Information message: Welcome to Beijing!";
  DieWithCustomMessage("INFO",$error_summary, $error_details);
  return $result;
}

VBScript examples

Function recordtype_ErrorMessage(param)
' param As Variant
' record type name is recordtype

REM add your hook code here

Dim error_summary
Dim error_details

error_summary="ReturnCustomErrorMessage"
error_details="Error message: Clicking this button will activate a computer virus!"

' $result=&DieWithCustomMessage($error_summary, $error_details,"ERROR");
call DieWithCustomMessage("ERROR",error_summary, error_details)
End Function

Function recordtype_WarningMessage(param)
' param As Variant
' record type name is recordtype

REM add your hook code here

Dim error_summary
Dim error_details

error_summary="ReturnCustomWarningMessage"
error_details="Warning message: Do not smoke at the work place!"

call DieWithCustomMessage("WARNING",error_summary, error_details)
End Function
Function recordtype_InfoMessage(param)
' param As Variant
' record type name is recordtype

REM add your hook code here

Dim error_summary
Dim error_details

error_summary="ReturnCustomInfoMessage"
error_details="Information message: Welcome to Beijing!" 

call DieWithCustomMessage("INFO",error_summary, error_details)
End Function