カスタム メッセージの生成

ClearQuest Web および ClearQuest Eclipse のクライアントでは、警告メッセージ パラメータを通常のフック エラー メッセージに埋め込むことで、フックがユーザーにエラー、警告、および情報の警告メッセージを示すことができます。ただし、ClearQuest for Windows のクライアント、ユーザーが記述したスクリプト、および古いクライアントが警告メッセージ パラメータを認識しない可能性があるため、以下のグローバル フックをスキーマに追加してから、そのグローバル フックを介してこの機能にアクセスする必要があります。このフックは、クライアントがカスタム メッセージをサポートしていない場合には通常の die ステートメントにメッセージ パラメータを使用しますが、クライアントがサポートしている場合にはカスタム メッセージを出して異常終了します。

以下の DieWithCustomMessage 関数は、die ステートメントを使用できるすべての場所から呼び出すことが可能で、現行操作での die ステートメントと同じ効果があります。例えば、アクセス制御フックから DieWithCustomMessage 関数を呼び出すと、die ステートメントが失敗を示す場合と全く同じように失敗を示しますが、カスタム メッセージを出します。

グローバル フック コードのダウンロード手順については、http://www.ibm.com/support/docview.wss?&rs=939&uid=swg21322606 のテクニカル ノート 1322606 を参照してください。

Perl 例

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 例

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

フィードバック