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.

Solved : Attachments uploading with 0kb size in ALM/QC using OTA

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'Create a TDConnection Object,TreeManager Object
Set UploadFolder = TreeMgr.NodeByPath(ALM_Upload_Folder)
Set tstAttachmentFactory = UploadFolder.Attachments
 
'Null refers to reserving space for a attachment
Set fileToUpload = tstAttachmentFactory.AddItem(Null)
 
'Provide full path of the file to attach
fileToUpload.Filename = "C:\Projects\Automation\abc.qfl"
 
'Add a description to the attachment
 fileToUpload.Description = "via Script"
 
'Add below line to avoid file upload with 0KB size,Specify type = 1(any file) 
 fileToUpload.Type = 1
 
'Finally attaches the file to specified node
 fileToUpload.Post

That’s it. If you miss the type you will end up with uploading file with 0kb.
In case of any issue or error still persists,leave a comment below.