How To Create A Folder In Test Plan In ALM/QC Using OTA API

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Function CreateFolderInTestPlan(FolderName As String)
 
    Dim TreeMgr As TreeManager
    Dim rootFolder
    Dim newFolder 
 
    Set newFolder = Nothing
 
'Create a treemanager object for accessing test plan tree hierarchy
    Set TreeMgr = TDConn.TreeManager
 
'Set rootFolder to subject node of test plan in alm
    Set rootFolder = TreeMgr.NodeByPath("Subject")
 
'Check if folder exists
    Set newFolder = rootFolder.FindChildNode(FolderName )
 
'If doesnt exists then create
    If newFolder Is Nothing Then
        Set newFolder = rootFolder.AddNode(FolderName )
        newFolder.Post
    End If
 
End Function

This function lets you create a new folder under test plan. TDConn is the TDConnection object. Make sure ALM connection has been created. Create a error handler if you need.