ALM Open Test Architecture API Reference Version 12.55
Getting the requirements associated with a defect
Function BugReqLink (aBug As Bug) As Boolean
    Dim BugF As BugFactory, reqF As ReqFactory
    Dim BugFilter As TDFilter, ReqFilter As TDFilter
    Dim aReq As Req, reqL As List
    Dim thisBug As Bug, bugL As List

' Getting the requirements associated with a defect

        
'This example outputs all the requirements linked to the Bug
' passed as an input argument.
    On Error GoTo FUNC_ERR
    BugReqLink = SUCCESS
    
'Set up the cross filter that specifies only this bug.
    'tdc is the global TDConnection object.
    Set BugF = tdc.BugFactory
    Set BugFilter = BugF.Filter
 
    BugFilter.Filter("BG_BUG_ID") = aBug.ID
    
    Set bugL = BugFilter.NewList
    For Each thisBug In bugL
        Debug.Print thisBug.ID, thisBug.Summary
    Next thisBug
'Set up the primary filter to get requirements.
'  There is no Filter property set, so all requirements are returned.
    Set reqF = tdc.ReqFactory
    Set ReqFilter = reqF.Filter
'Add the cross filter. The filter now means "Return
' all requirements associated with the bugs specified
'  by the cross filter, in this case, a single Bug.
    ReqFilter.SetXFilter "REQ-BUG", True, BugFilter.Text
  
    Set reqL = reqF.NewList(ReqFilter.Text)
' Check the results.
    If reqL.Count > 0 Then
        For Each aReq In reqL
            Debug.Print aReq.name
        Next aReq
    Else
         BugReqLink = FAILURE
         errmsg = "No bug links found"
         ErrHandler err, "BugReqLink", errmsg, NON_FATAL_ERROR
    End If
    
Exit Function
FUNC_ERR:
    BugReqLink = FAILURE
    ErrHandler err, "BugReqLink", errmsg, FATAL_ERROR
    
End Function