Example: Copying Field Values to Another Object

This example shows how to use the TDConnection object to copy the value from the Build Number field of a Run (RN_USER_02) to the Last Ran On Build field of a Test in a Test Set (TC_USER_03).

Add the code to the Run_AfterPost event procedure.

Sub Run_AfterPost
        On Error Resume Next
        Dim tdc
        set tdc = TDConnection
        Dim TSFact 'As TestSetFactory
        Set TSFact = tdc.TestSetFactory
        Dim TstSet 'As TestSet
        Set TstSet = TSFact.Item(Run_Fields("RN_CYCLE_ID").Value)
        MsgBox TstSet.Name
        Dim TSTestFact 'As TSTestFactory
        Set TSTestFact = TstSet.TSTestFactory
        Dim TSTst 'As TSTest
        Set TSTst = _
	 TSTestFact.Item(Run_Fields("RN_TESTCYCL_ID").Value)
        MsgBox TSTst.Name
         
        TSTst.Field("tc_user_03").value = _
	 Run_Fields("RN_USER_02").Value
        TSTst.Post
         
        PrintError ("Run_AfterPost")
        On Error GoTo 0
End Sub