Deep Patel: QC OTA code for getting Bug/Defect History

Monday, January 21, 2013

QC OTA code for getting Bug/Defect History

Get all the required history details of a Defect/Bug in QC using the OTA apis.

Use the below code to access the history of a defect

Dim BugFactory, BugList
Set BugFactory = QCConnection.BugFactory  
Set bugFilter = BugFactory.FilterSet BugList = bugFilter.NewList
Set Bug = BugList(0) 'gives the first bug in bug list

Set hst = Bug.history
Set hstList = hst.NewList("")
For j = 1 To hstList.Count
                Set hstRec = hstList.Item(j)
                HTMLMSg_Content = HTMLMSg_Content & " " & hstRec.FieldName
                HTMLMSg_Content = HTMLMSg_Content & "
"
                HTMLMSg_Content = HTMLMSg_Content & hstRec.ChangeDate & "
"
                HTMLMSg_Content = HTMLMSg_Content & "" & hstRec.NewValue & "
" 'Target Test Date
Next j


To get specific items from the list use if conditions as below:

Set hst = Bug.history
Set hstList = hst.NewList("")
For j = 1 To hstList.Count
                Set hstRec = hstList.Item(j)
                If hstRec.FieldName = "BG_STATUS" And hstRec.NewValue = "Ready to Test" Then
                                'HTMLMSg_Content = HTMLMSg_Content & " " & hstRec.FieldName
                                'HTMLMSg_Content = HTMLMSg_Content & "
"
                                HTMLMSg_Table2 = HTMLMSg_Table2 & "" & hstRec.ChangeDate & ""
                                'HTMLMSg_Content = HTMLMSg_Content & hstRec.ChangeDate & "
"
                                'HTMLMSg_Content = HTMLMSg_Content & "" & hstRec.NewValue & "
" 'Target Test Date
                                Exit For
                 End If
Next j

No comments:

Post a Comment