Search code examples
alm

Replace all in a specific folder


In my Test Plan I have two folders. One with all my active test cases and one with all my archived test cases. I need to replace a lot of 'Affected Module' from one value to another, however - I don't want the folder with archived to be affected by this.

So, is there a way of doing search and replace only on a specific folder (and all the sub-folders) in HP ALM?

As far as I know the search and replace function in grid view replaces all instances of the value so I can't use that directly.


Solution

  • Here is a simple OTA code that updates the field ts_user_04 for all the test case in folder Subject\Automated and its sub-folder from whatever value to Quoting.

    Please, change the column name as per your requirement. You can easily find the DB column for any field in HP ALM by going to the Management tab if you have access to it. Even otherwise you can get all the mapping by using OTA. (I hope you have the necessary access)

    Inorder to run the OTA code, you need to install ALM Connectivity add-in which you can get it from the tools section in your ALM home page

    Public TDconnection
    Public reqPath
    Public testPath
    
    'Call the main Function
    updateAllTests
    
    
    
    Public Function login()
        Dim almURL, almUserName, almPassword, domain, project
        almURL = "https://.saas.hp.com/qcbin/"
    
        almUserName = ""
        almPassword = ""
        domain = ""
        project = ""    
        testPath = "Subject\Automated" ' Change it as per your folder structure
    
        Set TDconnection = CreateObject("tdapiole80.tdconnection")
        TDconnection.ReleaseConnection
        TDconnection.InitConnectionEx almURL
        TDconnection.login almUserName, almPassword
        TDconnection.Connect domain, project
    
    End Function
    
    
    Public Function updateAllTests()
        login   
        Set TreeMgr = TDconnection.TreeManager
        Set TestTree = TreeMgr.NodeByPath(testPath)
        If Err.Number = 0 Then
            Set comm = TDconnection.Command
            comm.CommandText = "update test set ts_user_04='Quoting' where ts_test_id in (select ts_test_id from test, all_lists where ts_subject in (select al_item_id from all_lists where al_absolute_path like (select al_absolute_path from all_lists where al_item_id=" & TestTree.NodeID & ") || '%' ) and ts_subject = al_item_id)"
            comm.Execute
        End If
        logout
        MsgBox "Flag Update successful", vbInformation
    End Function
    
    Public Function logout()
        TDconnection.Disconnect
        TDconnection.logout
        TDconnection.ReleaseConnection
        Set TDconnection = Nothing
    End Function