GSU_CQXE_OpenForm 및 GSU_CQXE_OpenSubmitForm 글로벌 후크를 사용하면 후크의 미리 채워진 양식을 열 수 있습니다. 글로벌 후크를 스키마에 추가한 후 글로벌 후크에 액세스하여 양식의 레코드 유형을 지정하고 필드 값을 초기화할 수 있습니다.
이 기능은 ClearQuest® 클라이언트 및 ClearQuest Web에서 사용할 수 있습니다. 사용자가 기존 버전의 클라이언트나 Windows용 ClearQuest 클라이언트에서 양식을 열려고 시도하면 API가 정보 메시지를 리턴합니다. 이 메시지를 사용자에게 표시하려면 die 함수를 호출하십시오.
클라이언트에서 이 기능을 지원하는 경우에는 예외가 발생하면서 API 호출 이후의 코드가 실행되지 않습니다. 스크립트의 콜백 후크를 사용하여 API 호출 이후의 추가 코드를 실행하십시오.
패키지 적용에 대한 자세한 정보는 패키지 적용을 참조하십시오.
글로벌 후크가 포함된 다음과 같은 레코드 및 조치 스크립트 예제를 사용하여 사용자에게 미리 채워진 양식을 제공할 수 있습니다. 이 예제에서는 CreateChildDefect 조치가 Record Script 후크의 값으로 미리 채워진 제출 양식을 엽니다. 사용자가 양식을 취소하거나 저장할 수 있으며, 이 경우 RecordScriptCancel 및 RecordScriptSave 후크의 코드가 실행됩니다.
sub Defect_RecordScript {
my($result);
my($param) = @_;
# record type name is Defect
$currentSession= $entity->GetSession();
$newentity = $currentSession->BuildEntity("Defect");
$headline = $entity->GetFieldValue("Headline")->GetValue();
$id = $entity->GetFieldValue("id")->GetValue();
$newentity->SetFieldValue("Headline", "Child Of [".$id."] ".$headline);
$newentity->SetFieldValue("Severity", "3-Average");
# For multiple-line (Choice list) values
$newentity->SetFieldValue("Symptoms", "Data Loss\nSlow Performance");
# For reference-list fields
$newentity->AddFieldValue("customer", "123 smith");
$newentity->AddFieldValue("customer", "Ethan Hunt");
# For Date fieldType
$newentity->SetFieldValue("dateTime", "2010-04-08 15:57:28");
# For multiple-line (textArea) fieldType, support "\n","\t"special characters
$newentity->SetFieldValue("Description", "Description");
# Call back hooks need be defined in "record scripts" under $recordType
$save_callback_hook_name="RecordScriptSave";
# Set the orders of the fields, must include all field names
$fieldOrder = ["Headline","Severity","Symptoms","customer","dateTime","Description"];
$returnValue=GSU_CQXE_OpenSubmitForm($newentity,$save_callback_hook_name, "RecordScriptCancel", $fieldOrder);
if($returnValue){
# If the client doesn't support the global hook, execute the hooks there,
# e.g. validate and submit $newentity
# Win32::MsgBox("This function is not supported by the client.");
}
return $result;
}
sub Defect_RecordScriptSave {
my($result);
my($param) = @_;
# record type name is Defect
@params = split (/\n+/, $param);
$entity->EditEntity("Modify");
$entity->AddFieldValue("children",$params[1]);
$entity->Validate();
$entity->Commit();
return $result;
}
sub Defect_RecordScriptCancel {
my($result);
my($param) = @_;
# record type name is Defect
$error_summary="CancelBackSaveHook";
$error_details="No parameters were specified.";
# $result=&DieWithCustomMessage;("ERROR",$error_summary, $error_details);
DieWithCustomMessage("INFO", $error_summary, $error_details);
return $result;
}
Function Defect_RecordScript(param)
' param As Variant
' record type name is Defect
Dim currentSession
Dim newentity
Dim this_entity
Dim fieldOrder
Dim returnValue
Dim saveHookName
Dim cancelHookName
set currentSession = GetSession set newentity= currentSession.BuildEntity ("defect")
newentity.SetFieldValue "Headline", "Child Of parent record "
newentity.SetFieldValue "Severity", "3-Average"
' For multiple-line (Choice list) values
newentity.AddFieldValue "Symptoms", "Data Loss"
newentity.AddFieldValue "Symptoms", "Slow Performance"
' For reference-list fields
newentity.AddFieldValue "customer", "Ethan Hunt"
' For Date fieldType
newentity.SetFieldValue "dateTime", "2010-04-08 15:57:28"
' For multiple-line (textArea) fieldType, support vbcrlf special characters
newentity.SetFieldValue "Description", "Data Loss" & vbcrlf & "Slow Performance Unexpected Behavior" & vbcrlf & "retr"
ReDim fieldOrder(6) 'This sets up an array of seven elements with subscripts from 0 to 5
fieldOrder(0)="Headline"
fieldOrder(1)="Severity"
fieldOrder(2)="Symptoms"
fieldOrder(3)="customer"
fieldOrder(4)="dateTime"
fieldOrder(5)="Description"
saveHookName="RecordScriptSave"
cancelHookName="RecordScriptCancel"
Defect_RecordScript=GSU_CQXE_OpenSubmitForm(newentity,saveHookName,cancelHookName,fieldOrder)
If Defect_RecordScript <> "" then
' If the client doesn't support the global hook, excute the hooks there,
' e.g. validate and submit $newentity
' MsgBox "This function is not supported by the client."
End If
End Function
Function Defect_RecordScriptSave(param)
' param As Variant
' record type name is Defect
REM add your hook code here
Dim error_summary
Dim error_details
error_summary="Submit record has been saved."
error_details="The submit record information is:" & param
call DieWithCustomMessage("INFO", error_summary, error_details)
End Function
Function Defect_RecordScriptCancel(param)
' param As Variant
' record type name is Defect
REM add your hook code here
Dim error_summary
Dim error_details
error_summary="CancelBackSaveHook"
error_details="No parameters were specified."
call DieWithCustomMessage("INFO",error_summary, error_details)
End Function