ALM/QC – How to Update a Defect using OTA

Software Testing Published on:
Code Hacker

The question of the week comes one of my co-workers who asked:

I'm looking to use the ALM11 API to update a field within an existing Defect. I know you are using the API to create Defects. Have you (or know how to) update a field on an existing Defect?”

OTA Code to Update a Defect in ALM/QC

The following example updates a defect that has the ID of 17 and changes the status field to Fixed. The code is pretty straight forward and uses the OTA's BugFactory object to accomplish our goal. Creating an instance of the BugFactory object allows us to access all the services needed to manage defect records.

set tdc = createobject("TDApiOle80.TDConnection")
tdc.InitConnectionEx "http://yourURL/qcbin"
tdc.Login "yourName","yourPassword"
tdc.Connect "yourDomain","yourProject"
DefectID = 17
Set BugFactory = tdc.BugFactory
Set BugFilter = BugFactory.Filter
BugFilter.Filter("BG_BUG_ID") = DefectID
Set BugList = BugFilter.NewList
Set myBug = BugList.Item(1)
'Just need to know the qc field name value
myBug.Field("BG_STATUS") = "Fixed"
Set BugFilter = Nothing
Set myBug = Nothing
Set BugFactory = Nothing
Set BugFilter = Nothing

How to run the  OTA code

To run the defect code you can either place it in QTP and run as a script or place the code in a text file and save as a .VBS vbscript file.

Of course you will be using the field names found in your ALM project. If you don't know what the actual field names are, you can easily find them by going into QC's Tools>Customize. In the Project Customization section and go into the “Project Entities” section. Under the Project Entities Tree view click expand Defect and click on your System Folder or User Fields. Clicking on a field will reveal the field name that you will need to use:

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
Code Hacker

Software Quality Management in TestOps

Posted on 08/31/2022

Quality is most likely foremost in your mind when building a new product, ...

Software Testers Directory: 14 Best Software Testing Tools in 2022

Posted on 05/20/2022

Software testing is a process in software development. It helps developers find and ...

The Ultimate Mobile Testing Guide: 11 Tips to Test Your App Effectively

Posted on 03/21/2022

Are you a tester who wants to excel in the team? Or a ...