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"
myBug.Post
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:

Joe Colantonio is the founder of TestGuild, an industry-leading platform for automation testing and software testing tools. With over 25 years of hands-on experience, he has worked with top enterprise companies, helped develop early test automation tools and frameworks, and runs the largest online automation testing conference, Automation Guild.
Joe is also the author of Automation Awesomeness: 260 Actionable Affirmations To Improve Your QA & Automation Testing Skills and the host of the TestGuild podcast, which he has released weekly since 2014, making it the longest-running podcast dedicated to automation testing. Over the years, he has interviewed top thought leaders in DevOps, AI-driven test automation, and software quality, shaping the conversation in the industry.
With a reach of over 400,000 across his YouTube channel, LinkedIn, email list, and other social channels, Joe’s insights impact thousands of testers and engineers worldwide.
He has worked with some of the top companies in software testing and automation, including Tricentis, Keysight, Applitools, and BrowserStack, as sponsors and partners, helping them connect with the right audience in the automation testing space.
Follow him on LinkedIn or check out more at TestGuild.com.
Related Posts
Mobile testing is the systematic process of evaluating mobile applications to ensure they function correctly, provide excellent user experience, and […]
Love it or hate it—Behavior Driven Development is still widely used. And unfortunately still miss-understood. You’ve probably heard a lot […]
ETL stands for Extraction, Transformation, and Load (ETL). How do you test it? This guide covers what you need to know to get started.
I originally wrote this post in 2012 but I still get email asking if it is still possible to use […]


