Sunday, January 26, 2014

How to copy the value of a user-defined field in Test Plan to a user-defined field in Test Lab

This VBScript Workflow example will populate a test lab test instance user-defined field (TC_USER_01), with the value of a test plan user-defined field (TS_USER_01) of the corresponding test.

Sub TestSetTests_MoveTo
  TestSetTest_Fields("TC_USER_01").IsReadOnly = True
End Sub

Sub TestSet_MoveTo
    On Error Resume Next
    Dim td
    Dim testSetF
    Dim testSet1
    Dim testSetTestF
    Dim tstestL
    Dim tsTest
    Dim tFactory
    Dim tItem
    Set td = TDConnection
    Set testSetF = td.testsetFactory
    Set tFactory = td.TestFactory
    Set testSet1 = testSetF.Item(TestSet_Fields.Field("CY_CYCLE_ID").Value)
    Set testSetTestF = testSet1.TSTestFactory
    Set tstestL = testSetTestF.NewList("")
    For Each tsTest in tstestL
        'check if the UDF of the test instance is empty

        If Len(tsTest.Field("TC_USER_01")) = 0 Then
            Set tItem = tFactory.Item(tsTest.Field("TC_TEST_ID"))
            tsTest.Field("TC_USER_01") = tItem.Field("TS_USER_01")
       End If
    On Error GoTo 0
End Sub

1 comment:

  1. Hi,

    I applied this solution to my project and it didn't work. can you help please?