Question

I am trying to list QC11 project and domain name in combo box on form load() but I am getting error object required,code I am using:

Dim tdc As New TDAPIOLELib.TDConnection
Dim projectList As Customization
Dim Project As Customization
Dim Domain As Customization
Set tdc = CreateObject("TDApiOle80.TDConnection")
tdc.InitConnectionEx "https://xyz/omu"
For Each Domain In TheTDConnection.DomainsList
    Set projectList = tdc.GetAllVisibleProjectDescriptors
    For Each Project In projectList
        ComboBox1.AddItem (Project.Name)
        ComboBox2.AddItem (Project.DomainName)
    Next Project
Next Domain
Was it helpful?

Solution

If that's really the code you are using, then for a start this line is probably generating an error:

For Each Domain In TheTDConnection.DomainsList

Based on the rest of your code "TheTDConnection" should be "tdc":

For Each Domain In tdc.DomainsList

Oh, and to be doing this you should almost certainly be logged in first by calling tdc.Login... rather than just connected to the server.

On a related note, the DomainsList property is deprecated. I think you can just loop through the List of ProjectDescriptor objects returned by GetAllVisibleProjectDescriptors since that covers all projects under all domains that the current logged on user has access to.

Edit: this is a complete solution based on the original question. Here's working tested code that will cycle through the domains/projects that the provided user has access to. This assumes you have the QC/ALM Connectivity add-in installed (required).

If you are running this piece of VBScript on a 64 bit machine you need to run it using the 32bit version of wscript.exe: C:\Windows\SysWOW64\wscript.exe "c:\somewhere\myscript.vbs"

msgbox "Creating connection object"
Dim tdc
Set tdc = CreateObject("TDApiOle80.TDConnection")
msgbox "Connecting to QC/ALM"
tdc.InitConnectionEx "http://<yourServer>/qcbin/"
msgbox "Logging in"
tdc.Login "<username>", "<password>"
Dim projDesc
msgbox "Getting project descriptors"
Set projectDescriptors = tdc.GetAllVisibleProjectDescriptors
For Each desc In projectDescriptors
    msgbox desc.DomainName & "\" & desc.Name
Next
msgbox "Logging out"
tdc.Logout
msgbox "Disconnecting"
tdc.Disconnect
msgbox "Releasing connection"
tdc.ReleaseConnection

Edit 2:

If you want to parse the resulting XML from sa.GetAllDomains into a list of ALL domain\project items on the server you can do this (This is VBScript since the original question & tag still mention it, and has been tested):

Set objDoc = CreateObject("MSXML.DOMDocument")
objDoc.Load "C:\yourXmlFile.xml"
Set objRoot = objDoc.documentElement

For Each domain in objRoot.selectNodes("TDXItem")
  For Each project in domain.selectNodes("PROJECTS_LIST/TDXItem")
    msgbox domain.selectSingleNode("DOMAIN_NAME").text & "\" & project.selectSingleNode("PROJECT_NAME").text
  Next
Next
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top