ALM Open Test Architecture API Reference Version 12.55
List defect associated with a requirement and requirements associated with a defect
Public Sub xFilter(reqID As Long)

' List defect associated with a requirement and requirements associated with a defect
    
' This sample demonstrates cross filters by "round-tripping."
' Get a list of defects associated with a requirement. Then
' take one of those defects, find the list of associated requirements,
' and find our original requirement.
    Dim ReqFilter As ITDFilter
    Dim BugFilter As ITDFilter
    Dim Bugs As IList, aBug As Bug
    Dim defectID As Long
    Dim Reqs As List, aReq As Req
' Get the filter objects.
    'tdc is the global TDConnection object.
    Set ReqFilter = tdc.ReqFactory.Filter
    Set BugFilter = tdc.BugFactory.Filter

'Set a simple requirement filter based on the ID.
    ReqFilter.Filter("RQ_REQ_ID") = reqID
    Debug.Print ReqFilter.Text
'    [Filter]{
'    TableName:REQ,
'    ColumnName:RQ_REQ_ID,
'    LogicalFilter:3,
'    VisualFilter:3,
'    NO_CASE:
'    }
    
'
'Set the defect cross filter based on the requirement filter.
    BugFilter.xFilter("BUG-REQ") = ReqFilter.Text
    Debug.Print BugFilter.Text
'    [Filter]{
'    FLT:[X],
'    FKEY:,
'    TYPE:BUG-REQ,
'    IN_IDS:"[Filter]{
'    TableName:REQ,
'    ColumnName:RQ_REQ_ID,
'    LogicalFilter:3,
'    VisualFilter:3,
'    NO_CASE:
'    }
'    "
'    }
'
' The Bugs list contains the defects associated with
'  requirement ReqID.
    Set Bugs = tdc.BugFactory.NewList(BugFilter.Text)
    For Each aBug In Bugs
        Debug.Print aBug.ID, aBug.Summary
        'Save the defect ID of the last defect in the list
        ' for use in getting the xFilter in the other direction.
        defectID = aBug.ID
    Next aBug
'    20  Mercury Tours site crash during execution of load test for Welcome Page
'    21  Welcome page download time during the load exceeds 10 seconds
'
'Now do it the other way - requirements based on defects.
'Get clean filters without the settings from above.
    Set ReqFilter = Nothing
    Set BugFilter = Nothing
    Set ReqFilter = tdc.ReqFactory.Filter
    Set BugFilter = tdc.BugFactory.Filter
'
'Set a simple defect filter based on the ID.
    BugFilter.Filter("BG_BUG_ID") = defectID
    Debug.Print BugFilter.Text
'    [Filter]{
'    TableName:BUG,
'    ColumnName:BG_BUG_ID,
'    LogicalFilter:21,
'    VisualFilter:21,
'    NO_CASE:
'    }
'
'Set the requirement cross filter based on the defect filter.
    ReqFilter.xFilter("REQ-BUG") = BugFilter.Text
    Debug.Print ReqFilter.Text
'    [Filter]{
'    FLT:[X],
'    FKEY:,
'    TYPE:REQ-BUG,
'    IN_IDS:"[Filter]{
'    TableName:BUG,
'    ColumnName:BG_BUG_ID,
'    LogicalFilter:21,
'    VisualFilter:21,
'    NO_CASE:
'    }
'    "
'    }
'
' The Reqs list contains the defects associated with defect.
    Set Reqs = tdc.ReqFactory.NewList(ReqFilter.Text)
    For Each aReq In Reqs
        Debug.Print aReq.ID, aReq.name
    Next aReq
'
' Note that the Reqs list included defect 3, which was used
' to create the simple requirement filter at the beginning.
'
'    3    Mercury Tours Application
'    96   Page Download Time
'    126  Connect To Site Transaction

End Sub