FileName

Description

Returns the path name of the attached file.

This is a read-only property; it can be viewed but not set.

Before the attachment has been committed to the database, this property contains the original path name of the file. However, after the attachment has been committed, the file exists in the database rather than in the file system, so the path information is removed. For example, if you add the file C:\projectsmyfilesexample.txt, it will have that full name until the record is committed, whereupon the name will be shortened to example.txt.

It is legal in HCL Compass to attach two files with the same name and different path information to the same database. HCL Compass does not rely on the filename alone when locating the file internally. Also, there is a filename length limitation of 50 characters.

Syntax

VBScript


attachment.FileName 

Perl


$attachment->GetFileName(); 
Identifier
Description
attachment
An Attachment object, representing the attachment of a file to a record.
Return value
A String containing the name of the attached file.

Example

VBScript

' This example assumes there is at least 1 attachment field
' and 1 attachment associated with the record.
set currentSession = GetSession
set attachFields = AttachmentFields
set attachField1 = attachFields.Item(0)
set theAttachments = attachField1.Attachments
For each attachment in theAttachments
     set thefileName = attachment.FileName 
     set thefileSize = attachment.FileSize 
     currentSession.OutputDebugString "Attached file: " & _
          thefileName & " - size: " & thefileSize 
Next

Perl

# This example assumes that there is at least 1 attachment
# field associated with the record. Otherwise, 
# GetAttachmentFields won't return anything interesting
# and an error would be generated

# Get the collection of attachment fields
$attachfields = $entity->GetAttachmentFields();

# Get the first attachment fields
$attachfield1 = $attachfields->Item(0)

# Now get the collection of attachments from the attachments field
$attachments = $attachfield1->GetAttachments();

# Retrieve the number of attachments for the for loop
$numattachments = $attachments->Count();

for ($x = 0 ; $x < $numattachments ; $x++)
 {
   # Retrieve the correct attachment
   $attachment = $attachments->Item($x);

   # Get the filename and filesize for the attachment and print out
   # the results
   $filename = $attachment->GetFileName(); 
   $filesize = $attachment->GetFileSize();
   $session->OutputDebugString("Attached file: ".$filename." - 
          size: ".$filesize);
 }