QTP – How to add a new folder to the QC Resource Module Using OTA

QC/ALM Published on:
Code Hacker

The question of the week comes from Venky who writes:

“Thanks for the excellent post. In addition, How would I add a ‘Resource Folder’ through API? Can you please help how to create resource folder throught API?

OTA Code to add a folder

Thanks for the question! This is how I would use OTA to add a folder to the Resource module:

Set qcConn = QCUtil.QCConnection
Set resRoot = qcConn.QCResourceFolderFactory.Root
Set newFolder = resRoot.QCResourceFolderFactory.AddItem(null)
newFolder.ParentId = resRoot.ID
newFolder.Name = ”

So what is happening here with OTA?

If you don't have it already you should download the QC OTA_API_Reference.chm help file. This file contains information on all the valid object methods and properties for Open Test Architecture Reference (OTA) API.

QCConnection object

You need to first return Quality Center's OTA QCConnection object. This object allows you to get the current QC session and provides access to the QC object model from QTP.

Set qcConn = QCUtil.QCConnection

QCResourceFolderFactory Object

Then you need to get the Root property of the QCResourceFolderFactory Object. The QCResourceFolderFactory manages the QC resource folders and it's Root property returns the root resource folder labeled ‘Resources'

Set resRoot = qcConn.QCResourceFolderFactory.Root

Next we need to use the QCResourceFolderFactory's AddItem method to create a new item object passing it a null value. Passing NULL as the argument creates a virtual object, one that does not appear in the project database. After creating the item, use the relevant object properties to fill the object, then use the Post method to save the object in the database. This is the recommended technique for creating most objects that will be saved in the database.

Post it!

Last pass the new folder name and post the change to QC:

newFolder.ParentId = resRoot.ID
newFolder.Name = “TestJoeDEMOAddResourceFolder”

New Resource Folder Created!

You should now have a new folder under the Resource folder in the Quality Center Test Resources module.

19 responses to “QTP – How to add a new folder to the QC Resource Module Using OTA”

  1. How to add a new resource of type “Test Resource” under a folder in the Resources Module of ALM/QC using VB Script.

  2. Hi,
    Thanks for the info on OTA.In my Project I am working on one requirement where I need to upload and Excel file as an Attachment to ALM/QC.I have written code for that using OTA.In that I used statement Attachment.Post to save the attachment
    to ALM.But at this statement QTP throwing popup message
    “you are not authorized to perform this action”. The Excel file name is appearing in ALM which we uploaded but the content we placed in the Excel is not getting uploaded(filesize in ALM is 0KB).Please let me know how to overcome this?

    • Udayakiran » Hi Uday – it sound like some sort of permission issues. What rights do you have in the QC project that you are trying to upload to? Are you able to manually perform this action without getting this error?

      • Im using ALM12.01 version, manually if i upload a file it is fine, uploaded with actual size. But if i do through OTA client, then only it is getting uploaded with size 0KB and some 1970 date. I tried with project admin credentials also. Please guide me how to resolve this issue.

  3. I want to know how to create that Test Resource under foldera as asked by Ravi in his post above

  4. hi Joe
    we have also same problem like udayakiran said.while post the file to ALM we are getting a error message like “Simple entity error” when execute post method.
    What could be the cause of error? can you pls tell us

  5. set tdc = QCUtil.QCConnection
    theShortFileName = “Assegno” ‘ This is the Name of the Resource in the Test Resource folder of QC– This should the avaliable in QC
    UploadFolder = “D:\Datasheet” ‘ Local System Folder
    UploadFile = “Assegno_data.xls” ‘File to be uploaded
    Set oResourceFactory = tdc.QCResourceFactory
    Set oRoot = oResourceFactory.NewList(“”)
    Set oSub = Nothing
    iTotalItems = oRoot.Count
    For ItemCtr = 1 To iTotalItems
    CurItem = oRoot.Item(ItemCtr).Name
    print CurItem
    If UCase(CurItem) = UCase(theShortFileName) Then
    Set oSub = oRoot.Item(ItemCtr)
    msgbox “found”
    Exit for
    End If
    oSub.Filename = UploadFile ‘ This is the file Which is der in the UploadFolder Path
    oSub.ResourceType = “Data table”
    oSub.UploadResource UploadFolder, True
    set oRoot = Nothing
    set oResourceFactory = Nothing

    line of error

    error message: Faild to post simple entity

  6. Looking for scripts / tools to do a bulk upload of test cases using the check-in and similarly if scripts whcih checks-out bulk test cases. Bascially, need to use the check-in and check-out feature of qc with huge test cases. – Any suggestion.

  7. Hi Author,

    How to delete a particular file placed in the QC Resource Tab.
    Ex.Report folder with 3 files available in QC ->Resources .

    Want to delete the 3 files from Report folder available in QC using QTP scripts.


  8. Hi Joe,
    I have a requirement with REST API, so that i need to generate few documents.
    Issue is I am new to this and can i have a sample of code or any examples, so that I can make the filter up from there or any documentation on the same would be much appreciated.


  9. Hi Joe,

    I am trying create folder and Subfolders in ALM in Resources section.
    The above code is working fine and created folder under Resources. But, I am not able to find solution to create subfolder under newly created folder.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Code Hacker