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
TestSet_MoveTo
TestSetTest_Fields("TC_USER_01").IsReadOnly = True
End Sub
TestSet_MoveTo
TestSetTest_Fields("TC_USER_01").IsReadOnly = True
End Sub
Sub TestSet_MoveTo
On Error Resume Next
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("")
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")
tsTest.Post
End If
Next
'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")
tsTest.Post
End If
Next
On Error GoTo 0
End Sub
End Sub