Los ganchos globales GSU_CQXE_OpenForm y GSU_CQXE_OpenSubmitForm permiten abrir formularios y ganchos previamente rellenados. Después de añadir los ganchos globales a un esquema, puede acceder a ellos para especificar el tipo de registro del formulario e inicializarlo con valores de campo.
Para obtener instrucciones sobre cómo descargar el código de enganche global consulte la nota técnica 1432968 en http://www.ibm.com/support/docview.wss?&rs=939&uid=swg21432969.
Esta funcionalidad está disponible en los clientes de ClearQuest para Eclipse y la Web. Si un usuario intenta abrir un formulario desde un cliente más antiguo o desde el cliente ClearQuest para Windows, la API devolverá un mensaje informativo. Para mostrar este mensaje al usuario, invoque la función die.
Si el cliente soporta esta función, el API lanzará una excepción y no se ejecutará ningún código después de la invocación del API. Utilice los enganches de devolución de llamada del script para ejecutar código adicional después de la invocación del API.
Utilice estos ejemplos de scripts de registro y acción con los ganchos globales para proporcionar a los usuarios formularios previamente rellenados. En este ejemplo, la acción CreateChildDefect abre un formulario de envío que está previamente rellenado con los valores del enganche Scripts de registro. El usuario puede cancelar o guardar el formulario, el cual ejecuta el código en los enganches RecordScriptCancel y RecordScriptSave.
sub Defect_RecordScript {
my($result);
my($param) = @_;
# record type name is Defect
$currentSession = $entity->GetSession();
$newentity = $currentSession->BuildEntity("Defect");
$headline = $entity->GetFieldStringValue("Headline");
$id = $entity->GetFieldStringValue("id");
$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", "Anne Johnson");
$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");
# Set the orders of the fields, must include all field names
$fieldNames = ["Headline","Severity","Symptoms","customer","dateTime","Description"];
$returnValue = GSU_CQXE_OpenSubmitForm($newentity, "RecordScriptSave", "RecordScriptCancel", $fieldNames);
if($returnValue){
# If the client doesn't support the global hook, execute the hooks there,
# e.g. validate and submit $newentity
}
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 params!";
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", "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 vbcrlf special characters
newentity.SetFieldValue "Description", "Data Loss" & vbcrlf & "Slow Performance Unexpected Behavior" & vbcrlf & "retr"
ReDim fieldOrder(6)
fieldOrder(0)="Headline"
fieldOrder(1)="Severity"
fieldOrder(2)="Symptoms"
fieldOrder(3)="customer"
fieldOrder(4)="dateTime"
fieldOrder(5)="Description"
saveHookName="RecordScriptSave"
cancelHookName="RecordScriptCancel"
Defect_RecordScript=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 params!"
call DieWithCustomMessage("INFO",error_summary, error_details)
End Function