Attachment objects

In HCL Compass the user can attach files to a record (that is, an Entity object) in an attachment field. A record representing a defect can have multiple attachment fields, and each field can have multiple attached files. For example, a record might have three separate attachment fields: one for source code files, one for engineering specifications, and one for documentation.

To manage attachment fields, each Entity object has an AttachmentFields object. To manage individual attachments, each AttachmentField has an Attachments object.

To traverse from an Entity object to an Attachment, you must first get the AttachmentFields object. As you traverse, you can distinguish a general path using the AttachmentField names. Once you are at the level of an actual collection of attachments, you can identify individual attachments using Description and FileName values.

Attachment objects
Description
AttachmentField Object
Represents a single attachment field in a record
AttachmentFields Object
Collection object that represents the attachment fields in a record
Attachment Object
Stores an attachment file and information about it
Attachments Object
Collection object that represents a set of attachments in one attachment field of a record

The AttachmentFields object is a collection of AttachmentField objects. It represents all of the attachment fields associated with a record. There can be only one AttachmentFields object associated with a record. This object contains one or more AttachmentField objects. Its methods provide access to the fields containing attachments.

The AttachmentField object represents a single attachment field in a record. A record can have multiple AttachmentField objects, each of which includes a single Attachments object. An AttachmentField can hold a collection of files, each stored in an individual Attachment object.

The Attachments object is a container object that stores one or more Attachment objects. An Attachments object is always associated with a single AttachmentField object. This object contains all collections the corresponding attachment field has and provides methods to count, get, add, and delete attachments.

An Attachment object contains a single attached file. An Attachment object contains information about a particular attachment such as its description, the original file name, file size, and provides ways to manipulate the attachment.

The following Entity object methods are used to store and manage attachments.

  • AttachmentFields (GetAttachmentFields for Perl)

    Get the access object. Every Entity object has exactly one AttachmentFields object with methods that manage attachment fields.

  • GetFieldNames

    Get the field names defined for this object. When you use the AttachmentFields object to make a traversal of attachment collections, you may want to know the field names in order to identify which path you want to follow. (Alternately, you can use indexes to get each AttachmentField.)

  • GetFieldType

    Get the data type of a field. If the return value is 7 (_ATTACHMENT_LIST), then the field is of type AttachmentField. This is useful if you have a field name but are not sure of its data type.

  • GetAllFieldValues

    Get information about all fields in this object. This is something you might normally do, because you fetch other kinds of values using FieldInfo.GetValue() and FieldInfo.GetValueAsList(). If you do have an array of FieldInfo objects, you can get each name with FieldInfo.GetName() and check each data type with FieldInfo.GetType().

For more information, see AttachmentFields of the Entity Object and "Getting and setting attachment information"