0

I have been trying to create a folder structure in QC Releases folder. I could traverse the existing number of folders but I couldn't find anything for adding new folder of my choice. Here is the Sub Routine that I wrote which I plan to call by sending a path to the function in the format "Releases\XYZ\ABC". First this code will ignore the Releases keyword from the path. Then I will find for Folder XYZ and if not found it should create it. Can someone please help me with the code to add a node. Then I can continue coding further. This is my first question here so please ignore my mistakes if any.

I have tried AddNode but it did not work.

Mentioned below is the code I have written so far :

Public Sub releasePath(strPath As String)

Dim arr, bflag
Set folderFactory = tdc.releaseFolderFactory
Set folderFactoryNode = folderFactory.Filter
Set releaselist = folderFactoryNode.newList()

arr = Split(strPath, "\")
bflag = False


relesefoldercount = releaselist.Count
For i = 1 To relesefoldercount
    Set releseitem = releaselist.Item(i)
    If releaselist.Item(i).Name = arr(1) Then            
        bflag = True
    End If

Next
If bflag = False Then
    'create folder xyz        
End

End Sub

  • In an OTA API documentation example, to crate a new ReleaseFolder, they first get the ReleaseFolderFactory object from the parent of the folder to create, call `AddItem(Null)` on that factory, set the Name of the ReleaseFolder and Post it. What exactly fails, when you call AddItem? On which object do you call AddItem? – Roland Nov 25 '14 at 09:26
  • I tried adding an item on the releaselist object. And the error reported is something object does not support this function. – Wings over Washington Nov 25 '14 at 10:23
  • I tried using the code given in the OTA API Reference as it is. But I get an error "Run-time error -2147220427(80040435)" which says "Your quality center session has been disconnected. Contact your System administrator for more information." This error occurs after the line 'relFolder.Post'. And when I check using tdc.Connected it returns True which means the session is not disconneted. – Wings over Washington Nov 25 '14 at 15:38

1 Answers1

1

First of all, I think your variable names are quite confusing. Your folderFactoryNode is a TDFilter object and your releaselist actually is a list of ReleaseFolder objects and not a list of Releases. To create a new ReleaseFolder you need to call AddItem of the ReleaseFolderFactory. In your case, to create the first level folders you need something like that (untested, directly from the OTA API documentation):

' Create a Release folder.
Set oReleaseFolderFactory = tdc.ReleaseFolderFactory
Set rootReleaseFolder = oReleaseFolderFactory.Root
Set oReleaseFolderFactory = rootReleaseFolder.ReleaseFolderFactory
Set relFolder = oReleaseFolderFactory.AddItem(Null)
relFolder.Name = "XYZ"
relFolder.Post

For deeper levels (the ABC folder in your example), you can use AddItem of the ReleaseFolderFactory of the XYZ folder.

Roland
  • 1,220
  • 1
  • 14
  • 29