In order to reference a defect / bug currently selected by a user in the Defect GridView the following method can be used.

Source Code

' @Author - Alexander Bolte
' @ChangeDate - 2014-10-31
' @Description - Returning the Bug currently selecetd by a user
' in Defect GridView.
' @Returns a Bug object referencing the bug currently
' selected by a user.
Function getSelectedDefect()
    Dim bg ' As Bug     Set bg = getBugById(Bug_Fields.Field("BG_BUG_ID").Value)     If err.Number <> 0 Then
        bg = Nothing
        Err.Clear()
    End If     Set getSelectedDefect = bg
End Function

Referenced Method(s)

Below method is used by above function and returns an object of type Bug identified by provided bug id.

' @Author - Alexander Bolte
' @Description - Returning an object of type Bug identified by provided BG_BUG_ID.
' @Param bugId - a String holding the bug id of a defect to be returned.
' @Returns an object of type Bug. If a Bug is not existing under given id Nothing is returned.
Function getBugById(bugId)
  Dim BugF
  Dim bg
  Dim BugList   ' Setting the bug factory.
  Set BugF = TDConnection.BugFactory   ' Creating the filter to search for rule id.
  Set fltr = BugF.Filter
  fltr.Filter("BG_BUG_ID") = bugId
  Set BugList = fltr.NewList()   If BugList.Count = 1 Then
     Set bg = BugList.Item(1)
  End If   Set bugList = Nothing
  Set bugF = Nothing   Set getBugById = bg
End Function