Delete

説明

添付ファイルをコレクションから削除します。

VBScript の場合、このメソッドの引数は、数値インデックス (itemNum) か表示名 (displayName) のいずれでもかまいません。Perl の場合、引数は数値インデックスでなければなりません。

Count および Item メソッドを使用すると、このメソッドを呼び出す前に正しい Attachment オブジェクトを特定できます。

注: Delete メソッドを呼び出す前に、エンティティは編集可能状態になっている必要があります。 Rational ClearQuest フックでこのメソッドを使用していて、現在のレコード (つまり、現在のアクションが進行中のレコード) から添付ファイルを削除する場合、エンティティは既に編集可能状態になっています。しかし、フックでこのメソッドを使用していて、現在のエンティティ以外のレコードから添付ファイルを削除する場合、または外部プログラムでこのメソッドを使用する場合は、まず EditEntity メソッドを呼び出して、エンティティを編集可能状態にする必要があります。 詳しくは、EditEntity メソッドを参照してください。

構文

VBScript

attachments.Delete itemNum 
attachments.Delete displayName 

Perl

$attachments->Delete(itemNum); 
識別子
説明
attachments
Attachments コレクション オブジェクト。レコードの 1 つのフィールドの添付ファイルのセットを表します。
itemNum
VBScript の場合、コレクションのインデックスである Variant。 このインデックスは 0 ベースで、削除するファイルを指します。Perl の場合、コレクションのインデックスである Long。このインデックスは 0 ベースで、削除するファイルを指します。
displayName
VBScript の場合、コレクション内のアイテムの表示名である Variant。
戻り値
ファイルが正常に削除された場合は True、そうでない場合は False の Boolean。

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

フィードバック