미리 채워진 양식 열기

설명

GSU_CQXE_OpenFormGSU_CQXE_OpenSubmitForm 글로벌 후크는 후크에서 미리 채워진 양식을 열기 위한 기능을 제공합니다. 스키마에 글로벌 후크를 추가한 후 여기에 액세스하여 양식의 레코드 유형을 지정하고 필드 값으로 초기화할 수 있습니다.

이 기능은 ClearQuest® Client 및 ClearQuest Web에서 사용할 수 있습니다. 사용자가 이전 클라이언트 또는 Windows용 ClearQuest 클라이언트의 양식을 열려고 시도하는 경우 API가 정보 메시지를 리턴합니다. 이 메시지를 사용자에게 표시하려면 die 함수를 호출하십시오.

클라이언트가 이 기능을 지원하는 경우 API에 예외가 발생하며 API 호출 후 코드가 실행되지 않습니다. 스크립트의 콜백 후크를 사용하여 API 호출 후의 추가 코드를 실행하십시오.

참고: GSU_CQXE_OpenSubmitForm API에는 데이터베이스 ID를 사용하는 임시 CQEntitiy 오브젝트가 필요합니다. 성능 향상을 위해 이 함수에 GSU_CQXE_SubmitForm 데이터베이스 ID를 사용할 수 있습니다. GSU_CQXE_SubmitRecord API를 사용하여 양식을 여십시오. 세부사항은 GSU_CQXE_SubmitRecord API를 사용하여 미리 채워진 양식 열기의 내용을 참조하십시오.
GSU_CQXE_OpenFormGSU_CQXE_OpenSubmitForm 글로벌 후크 함수는 GlobalScriptUtility(GSU_CQXE) 패키지에서 제공됩니다. 이러한 함수를 사용하기 전에 이 패키지를 적용해야 합니다.
  1. ClearQuest Designer에서 패키지를 적용하려는 스키마의 버전을 마우스 오른쪽 단추로 클릭한 후 패키지 > 패키지 적용을 클릭하십시오. 패키지 마법사가 열립니다.
  2. 패키지 목록에서 GlobalScriptUtility 노드를 펼치고 버전 1.0을 선택하십시오. 다음을 클릭하십시오.
  3. 패키지를 적용할 레코드 유형을 선택하십시오. 완료를 클릭하십시오.
이제 GlobalScriptUtility 패키지가 선택한 스키마에 적용됩니다. 패키지 설치를 확인하려면 스키마에서 새 GSU_CQXE 글로벌 스크립트를 찾으십시오.

패키지 적용에 대한 자세한 정보는 패키지 적용의 내용을 참조하십시오.

예제

글로벌 후크가 있는 조치 스크립트 및 레코드의 예제를 사용하여 사용자에게 미리 채워진 양식을 제공하십시오. 이 예제에서 CreateChildDefect 조치는 Record Script 후크의 값으로 미리 채워진 제출 양식을 엽니다. 사용자는 RecordScriptCancelRecordScriptSave 후크에서 코드를 실행하는 양식을 취소하거나 저장할 수 있습니다.

이 예제를 사용하려면 스키마를 다음과 같이 변경하십시오.
  1. 결함 레코드 유형에 두 개의 새 필드(dateTime이라고 하는 DATE_TIME 필드 및 children이라고 하는 REFERENCE_LIST 필드)를 추가하십시오.
  2. children 필드의 참조 속성을 결함으로 설정하십시오.
  3. 아래의 Perl 또는 VBScript 코드 예제를 사용하여 RecordScript, RecordScriptSave, RecordScriptCancel라고 하는 세 개의 레코드 스크립트를 작성하십시오.
  4. 결함 레코드 유형에 CreateChildDefect라고 하는 새 RECORD_SCRIPT_ALIAS 조치를 추가하십시오. 위에서 작성한 RecordScript 후크를 사용하도록 CreateChildDefect 조치를 설정하십시오.
  5. 결함 레코드 유형의 Defect_Base 양식에 OpenForm이라고 하는 새 탭을 추가하십시오.
  6. 새 OpenForm 탭에서 다음 제어를 추가하십시오.
    • 날짜시간 둘 다를 표시하도록 설정된 텍스트 필드입니다. 날짜 표시 형식으로 자세한 날짜를 선택하십시오. 소스 필드로 dateTime을 선택하십시오.
    • 소스 필드가 하위로 설정된 상위/하위 제어입니다.
참고: 이러한 코드 예제 중 일부는 DieWithCustomMessage 함수를 사용하여 API에서 리턴된 오류 메시지를 처리합니다. 이 글로벌 스크립트에 대한 자세한 정보는 사용자 정의 오류 메시지 생성을 참조하십시오.

Perl 예제

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;
}

VBScript 예제

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

피드백