If you have to reference attachments in HP ALM Defects module the following script might give you a hint on how to implement it.

Source Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
' @Author - Alexander Bolte
' @Changed - 2013-12-20
' @Description - Returns a List object holding references to filtered Attachment objects
' from given Bugs AttachmentFactory.
' @Param bugger - an object of type Bug an attachment should be gotten from.
' @Param fileName - a unique file name including file extension to identify 
' an attachment to download.
' @Returns Nothing, if it fails, else a collection of type List holding
' references to filtered attachments.
Function getDefectAttachment(bugger, fileName) ' As List
    Dim attachFac ' As AttachmentFactory
    Dim attach ' As Attachment
    Dim attachFilter ' As Filter
    Dim attachList ' As List
 
    On Error Resume Next
 
    ' Bug object must be initialized.
    If Not (bugger Is Nothing) Then
        ' Reference the bugs attachment factory.
        attachFac = bugger.Attachments
 
        ' Get an attachment filter.
        attachFilter = attachFac.Filter
        ' Setup a new filter for an attachment.
        attachFilter.Filter("CR_REFERENCE") = """BUG_" & bugger.ID & "_" & fileName & """"
        ' Reference the list of filtered attachments as returned object.
        attachList = attachFilter.NewList()
    Else
        attachList = Nothing
    End If
 
    ' Return a list object holding references to filtered attachments.
    getDefectAttachment = attachList
 
    If err.Number <> 0 Then
        err.clear()
    End If
 
    attach = Nothing
    attachFilter = Nothing
    attachFac = Nothing
    bugger = Nothing
End Function