Creating Defects

This test creates a defect on OpenText Application Quality Management. A similar VBScript example can be found in the AddDefectToQC.vbs file located in the <Installdir>\CodeSamplesPlus folder.

This example is written in VBScript. To write similar code in Python, replace programming language statements with Python ones, use the print method instead of MsgBox, and make other syntax adjustments as necessary.

Copy code
Dim TDConnection
Set TDConnection = CreateObject("TDApiOle80.TDConnection")
 
TDConnection.InitConnection "http://myALMServer:8080/qcbin" ' URL
TDConnection.Login "<MyUser>", "<MyPassword>" ' Log on to server
TDConnection.Connect "<MyDomain>", "<ALMProject>" ' Connect to the domain and project

If TDConnection.Connected Then
    MsgBox("Connected to " + chr (13) + "Server " + TDConnection.ServerName _
    + chr (13) +"Project " + TDConnection.ProjectName )
Else
    MsgBox("Not Connected")
End If
 
'Get the IBugFactory
Set BugFactory = TDConnection.BugFactory
 
'Add a new empty bug
Set Bug = BugFactory.AddItem (Null)
 
'fill the bug with relevant parameters
Bug.Status = "New"
Bug.Summary = "Connecting to ALM"
Bug.Priority = "4-Very High" ' depends on the settings
Bug.AssignedTo = "<MyUser>" ' user that must exist in the users list
Bug.DetectedBy = "<MyUser>" ' user that must exist in the users list
Bug.Field("BG_DETECTION_DATE") = FormatDateTime(Now, 2)
Bug.Field("BG_SEVERITY") = "4-Very High" ' depends on the settings

'Post the bug (commit)
Bug.Post