0

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
Koby Douek
  • 16,156
  • 19
  • 74
  • 103
user635545
  • 111
  • 1
  • 4
  • 12
  • Which statement is generating the "object required" error? – Xiaofu Apr 09 '14 at 13:37
  • You have almost completely changed your code. Your original question was nothing to do with IXMLDOMNodeList and related to getting domains & projects from the ALM API. If that is solved then you should ask a different question for your file parsing needs. – Xiaofu Apr 11 '14 at 07:06
  • ...and using a different API now too! (was OTA API, now the SiteAdmin API) – Xiaofu Apr 11 '14 at 07:14
  • no issue didnot get resolved so i am trying to modify the code to get the solution – user635545 Apr 11 '14 at 08:54
  • I have added a tested working solution that cycles through the domains/project that your user has access to. – Xiaofu Apr 11 '14 at 10:22
  • I see where you're going with the SA and the XML parsing, but that really is almost a totally different questions to the original, not to mention things have apparently now morphed from VBScript to a VB application. – Xiaofu Apr 11 '14 at 10:40
  • 1
    I'm obviously a masochist. Edit 2 in my answer will parse the XML from sa.GetAllDomains. – Xiaofu Apr 11 '14 at 11:17

1 Answers1

0

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
Xiaofu
  • 15,523
  • 2
  • 32
  • 45
  • Looking at the OP's code, they are not doing anything with the Domain object anyway, at least not in the posted snippet. – Xiaofu Apr 09 '14 at 13:50
  • @user635545 Have you tried adding code to login first? Can you be more specific and tell us which line is currently causing the error? – Xiaofu Apr 11 '14 at 07:02
  • Dim MyNodeList As IXMLDOMNodeList Line itself causing the error – user635545 Apr 11 '14 at 08:53
  • @Xiaofu: Could you please share a link where I can find a complete documentation on TDAPIOLELib.TDConnection? Thanks. – Ejaz Jan 29 '16 at 11:28