Delete

Descrizione

Elimina un file allegato dalla raccolta.

Per VBScript, l'argomento per questo metodo può essere un indice numerico (itemNum) o un nome di visualizzazione (displayName). Per Perl, l'argomento deve essere un indice numerico.

È possibile utilizzare i metodi Count e Item per individuare l'oggetto Attachment corretto prima di richiamare questo metodo.

Nota: l'entità deve trovarsi in uno stato modificabile prima di richiamare il metodo Delete. Se si sta utilizzando questo metodo in un hook di Rational ClearQuest e si sta eliminando un allegato dal record corrente (ovvero, il record su cui è in esecuzione l'azione corrente), l'entità è già in uno stato modificabile. Tuttavia, se si sta utilizzando questo metodo in un hook e si sta eliminando un allegato da un record diverso dall'entità corrente oppure se si sta utilizzando questo metodo in un programma esterno, per prima cosa è necessario che l'entità si trovi in uno stato modificabile tramite la chiamata al metodo EditEntity. Per ulteriori informazioni, consultare il metodo EditEntity.

Sintassi

VBScript

attachments.Delete itemNum 
attachments.Delete displayName 

Perl

$attachments->Delete(itemNum); 
Identificativo
Descrizione
attachments
Un oggetto Attachments, che rappresenta la serie di allegati in un campo di un record.
itemNum
Per VBScript, un valore Variant che corrisponde ad un indice nella raccolta. Questo indice è basato sul valore 0 e punta al file che si desidera eliminare. Per Perl, un valore Long che corrisponde ad un indice nella raccolta. Questo indice è basato sul valore 0 e punta al file che si desidera eliminare.
displayName
Per VBScript un valore Variant che corrisponde ad un nome di visualizzazione di un elemento nella raccolta.
Valore di ritorno
Un valore True booleano se il file è stato eliminato correttamente, in caso contrario un valore False booleano.

Esempi

VBScript

' This example assumes there is at least 1 attachment field in this record type,
' and at least one attachment associated with this record.
' NOTE: The entity must be in an editable state to delete an attachment -- see above.
set currentSession = GetSession
set attachFields = AttachmentFields
set attachField1 = attachFields.Item(0)
set theAttachments = attachField1.Attachments
If Not theAttachments.Delete(0) Then
    OutputDebugString "Error deleting the attachment."
End If

Perl

# This example assumes there is at least 1 attachment field in this record type,
#  and at least one attachment associated with this record.
# NOTE: The Entity must be in an editable state to delete an attachment -- see above.
# For this entity record, get the collection of all attachment fields
$attachfields = $entity->GetAttachmentFields();
# Work with the first attachment field
$attachfield1 = $attachfields->Item(0);
# For this attachment field, get the collection of all its attachments
$attachments = $attachfield1->GetAttachments();
# Delete the first attachment
if (!$attachments->Delete(0)) {
    $session->OutputDebugString("Error deleting attachment from record.\n");
}

Feedback