Quality Center / ALM Practitioners Forum
Showing results for 
Search instead for 
Did you mean: 

Quality Center VB Scripting

Acclaimed Contributor

Quality Center VB Scripting

Hey guys/gals,

I'm new to QC and would like to see some vb script examples.

Post away!

Thanks in advance,
Regular Collector

Re: Quality Center VB Scripting

QC is a test management tool. You do not need to know VB Scripting for it. Use of QTP requires VB Scripting.

Re: Quality Center VB Scripting

Hey jackon,

You want more info on VB script and QTP, you can check out my Blog.


Re: Quality Center VB Scripting

Hi Jackson

The last few years I wrote some thousend lines of VBScripts to enhance the possibilities of QC. It makes no sense to provide you with this information if you are not familiar with VBScipt. But I suggest to have a look to the scipts in a new project, you will see only the "empty" subs and functions. Then try the scripts wizards and look where and how the workflow is changed. A possibility is also to check the examples of scripts in the help (however they are not all working...).
Then just try to do some simple changes, you will get familiar with scripting quite soon.
Acclaimed Contributor

Re: Quality Center VB Scripting

Hi Marc,

I have extensive familiarity with vb scripting, and would not mind seeing some of your code snippets. I am just requesting some code snippets in order to get a "feel", if you will, for the scripting environment in QC.

Please get back to me.
Rhonda Robinson
Honored Contributor

Re: Quality Center VB Scripting

That's just it - you're being too vague.

There are lots of different code snippets available in the Administrator's Guide and/or the API Reference Manual.

There is code for sending email(s) to specific people in specific circumstances. There is code to make the Comments field Read Only. There is code to automatically complete one field based upon the value of another field. And on, and on, and on.

Please be specific in what you want to accomplish using the code, and someone may have an idea as to how to assist you.

Re: Quality Center VB Scripting

Hi Jackson

Yes, I agrre with ronda. If you have specific topics, a lot of people in this forum will help you. It make no sense to provide you with a lot of code if we don't know what you want to do.

Yossi T
Occasional Advisor

Re: Quality Center VB Scripting

hi there

im new to QC and would like to know how do i start writing scripts for QC.

i.e can some one please point me to a tutorial on how to make a "hello world" in the QC enviorment.


Re: Quality Center VB Scripting

Hi YossiT

Try it like this:

In Sub Req_MoveTo add the following code:

If User.UserName = "MyAccount" Then
MsgBox "Hello World!"
End If

Each time you move the cursor to a requirement, you will see the message. Please replace "MyAccount" with your account. The if clause is to prevent other users being affected with your code.

Have fun!
Regular Collector

Re: Quality Center VB Scripting

Hi Folks.


I also have some questions regarding vbscripting in the QC workflow.  I do understand some fundimental elements and have an idea of what I want done.   If there is another place in the forum where I should post this, just let me know.


I'm not sure if it's possible, if it's not that is going to be very dissapointing.  I've talked to HP Support, they don't support any customization.  Honestly, that's the only part I have questions regarding, the rest of QC/ALM seems pretty straight forward to me, but lacking in some options/features I'd like.


So, essentially, all I want to do is link some system/user fields from the req. module to the testing module so that when I generate tests from the requirements I can move some of the data from the fields over and not have to enter all the information twice.


I know I'm in the right place in the workflow because I put a message box and it pops up when I go to generate the test but I can't get any of the fields to actually sync up.  QC does this by default (guessing it's in the compiled code somewhere) when it comes to the "Description" field, but no others.


I'm guessing I'm not initiating the req.objects correctly so that the script picks them up to link them to the test fields.


Here is a snipppet of my code.


Sub Test_New
On Error Resume Next

  Dim Req_Fields
  Set Req_Fields = TDConnection.Req_Fields

  set tFactory = TDConnection.TestFactory
  testObj = tFactory.NewList("")

  reqList = testObj.GetCoverList

  MsgBox  "This is Where This Is!"

  set Test_Fields.Field("TS_USER_02").Value = Req_Fields.Field("RQ_USER_30").Value
  set Test_Fields.Field("TS_DEV_COMMENTS").Value = Req_Fields.Field("RQ_DEV_COMMENTS").Value
  set Test_Fields.Field("TS_USER_08").Value = Req_Fields.Field("RQ_USER_04").Value
  set Test_Fields.Field("TS_USER_013").Value = Req_Fields.Field("RQ_USER_08").Value

  On Error GoTo 0
End Sub

 Any help would be greatly appreciated.

Trudy Claspill
Honored Contributor

Re: Quality Center VB Scripting

One problem with your code is that Req_Fields is getting you the list of fields for a requirement, not the information for a specific requirement.

You need to first create variables that point at the specific Requirement and the specific Test where you want to synch the data. In some places in the workflow, the scripts automatically have access to the "current" entity being operated on - i.e. in a Test Plan workflow script, you may have a default object already pointing at the current Test Case entity. Most of the time that kind of default object only points to the entity relevant to your current module - a Requirement or a Test Case or.... So you will probably need to do some code to retrieve one or the other entity.

That's just a quick comment trying to point you in the right direction. If you haven't already, you should also look at the Administrator Guide sections on Workflow Customization. They have lots of examples, and talk about the default object variables I mentioned.
[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
Regular Collector

Re: Quality Center VB Scripting

Thanks Trudy,


I actually got this to work after I fixed my code.  It does seem rather flaky though.  It seems to work sometimes and sometimes it does not. 


I've experemented with checking-in, checking-out the requirements, tests it just seems really particular for some reason.  Perhaps like it's not catching it, I've removed the msgbox I had in the sub as I am certain I'm following the same process now.  I'm using QC 11, has anyone else had this issue?

Acclaimed Contributor

Re: Quality Center VB Scripting



Again: novice and probably repeating question. Sorry, could someone help with finding documentation and examples.


My task is:

we have small sproject which should create\update HP QC issues. 

For now I have all required values in separate Oracle DB. And I have link + user\password for HPQC


I'm sure that exist some automated possibilities for creating and closing issues in HP.


So, please, help me with starting point.

Acclaimed Contributor

Re: Quality Center VB Scripting

I see that the topic is 5 years old. May be someone is still looking into that.

In general VB Scripting in QC is poorly documented. If I want to do something similar to what Scripting wizard does the only way is to look into what is created by wizard, copy it and modify it which is not always works because there are many dependencies. 


These are examples of what I would sometimes need to accomplish:


There is a way to add more tabs in the defect module New and Modify screens. GUI allows to create 4 tabs and when I needed the 5th one I tried to copy the code. It did create some unexpected "side effects".


The scripting GUI exists only for DEFECTS module. I'd like to implement similar workflows for requirements module - like automail sent if some field are changed for some requirement types, its. Again, it is possible to "reingineer" it but there is a risk of unexpected side effects.

Anyone can help? Is there a decent document that would describe the modules, fields, relationships, etc. with code samples?

//Add this to "OnDomLoad" event