【问题标题】:How to extract Defects with linked TCs using QC OTA如何使用 QC OTA 提取具有链接 TC 的缺陷
【发布时间】:2020-08-14 23:06:29
【问题描述】:

我可以使用以下代码成功下载缺陷,但是如何针对每个缺陷获取状态为“失败或阻止”的链接 TC 的计数?

Sub GetDefectsByFilter()

On Error Resume Next
Dim a
Dim intIndex As Integer
Dim sngPercent As Single

Dim BugFactory, BugList, BgFilter
Dim Response As VbMsgBoxResult
Dim DefectID As String
If TDC Is Nothing Then ConnecttoQC
Set BugFactory = TDC.BugFactory
Set BgFilter = BugFactory.Filter
DefectID = frmDefectFilter.txtDefectID
BgFilter.Filter("BG_BUG_ID") = DefectID
Set BugList = BgFilter.NewList

Dim Bug, Row, Count As Integer
Count = 1
Row = 2
ActiveSheet.Cells(1, 1).Value = "Defect ID"
ActiveSheet.Cells(1, 2).Value = "Application"
ActiveSheet.Cells(1, 3).Value = "Status"

For Each Bug In BugList
    ActiveSheet.Cells(Row, 1).Value = Bug.Field("BG_BUG_ID")
    ActiveSheet.Cells(Row, 2).Value = Bug.Field("BG_USER_06")
    ActiveSheet.Cells(Row, 3).Value = Bug.Field("BG_STATUS")
    Row = Row + 1
    Count = Count + 1
Next
frmDefectFilter.Hide
End Sub

【问题讨论】:

  • OTA API 中有一个名为Getting the requirements associated with a Bug的示例,其中使用了交叉过滤器。您是否尝试过类似的方法来获得关联的 TC?

标签: vbscript hp-quality-center


【解决方案1】:

感谢@Roland。下面的代码 sn-p 帮助了我。

Sub ViewLinks()
'------------------------------------------------------
' Output all bug links.

Dim BugF As BugFactory, bList As List
Dim aBug As Bug
Dim bugL As ILinkable, LinkList As List, linkF As LinkFactory

   'tdc is the global TDConnection object.
Set BugF = tdc.BugFactory
Set bList = BugF.NewList("")

For Each aBug In bList
'Cast the Bug object to an ILinkable reference
' to get the link factory.
    Set bugL = aBug
    Set linkF = bugL.LinkFactory
    Set LinkList = linkF.NewList("")
    Dim SourceObj As Object, TargetObj As Object, InitObj As Object, lnk As Link
    Debug.Print: Debug.Print "---------------------------------"
    Debug.Print "Source Type"; Tab; "ID"; Tab; "Target Type"; _
        Tab; "ID"; Tab; "Initiated by"
    For Each lnk In LinkList
        With lnk
            Set SourceObj = .SourceEntity
            Set TargetObj = .TargetEntity
            Set InitObj = .LinkedByEntity
            Debug.Print TypeName(SourceObj); Tab; CStr(SourceObj.ID); _
                Tab; TypeName(TargetObj); Tab; CStr(TargetObj.ID); _
                Tab; TypeName(InitObj); Spc(3); InitObj.ID
        End With
    Next lnk
Next aBug

End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多