≡ Menu
Joe Colantonio – Selenium-UFT-QTP-SoapUI-ALM-LoadRunner & more

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

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

How to add a new folder to the QC Resource using OTA

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 = “
TestJoeDEMOAddResourceFolder”
newFolder.Post()

So what is happening here?

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”
newFolder.Post()

New Resource Folder Created!

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

14 comments… add one

  • Ravi

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

    • Joe Colantonio

      Ravi » Hi Ravi – check put my post: VIDEO – How to save a file to a QC resource using QTP with OTAVIDEO – How to save a file to a QC resource using QTP with OTA

      • Ravi

        I’ve seen that Joe. Here, I want to know how to create that Test Resource itself. I.e., I need to create a new test resource under a folder, to which we can upload any file as your video says.

        Please share your knowledge..Thanks.

        • Vinothkumar Manoor Chinnasamay

          Need infor for the same

  • Udayakiran

    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?
    Thanks
    uday.

    • Joe Colantonio

      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?

  • Vinothkumar Manoor Chinnasamay

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

  • ganesh

    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

  • ganesh

    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
    Next
    oSub.Filename = UploadFile ‘ This is the file Which is der in the UploadFolder Path
    oSub.ResourceType = “Data table”
    oSub.Post
    oSub.UploadResource UploadFolder, True
    set oRoot = Nothing
    set oResourceFactory = Nothing

    —————–
    line of error

    oSub.Post
    ——————
    error message: Faild to post simple entity

  • Kedara

    Hi Ganesh,
    pls set the Parameter Parameter to ‘N’ from Site admin-> Site Configuration.
    Hiran

    • Kedara

      oops parameter DISABLE_EXTENDED STORAGE TO N

  • Raghu

    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.

  • Thirunavukkarasu

    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.

    Thanks
    Thiru

Leave a Comment