Absent Member.. DTilford Absent Member..
Absent Member..
131 views

Pass Data from Test Plan User Field To Defect User Field

I created a Risk field(TS_User_07) within Test Plan module that have the values "High, Medium or Low". When a user submits a defect I need that value to passed to Defect Risk value(BG_USER_12) "High, Medium or Low".
0 Likes
7 Replies
Knowledge Partner
Knowledge Partner

Re: Pass Data from Test Plan User Field To Defect User Field

Hi,

this is quite common question. And you can find a lot of links how to make populate the field in new bug in manual runner from test.

My code that I use is here in these posts:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1214778
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1221500

Try it and change it to your environment.

Best Regards
Vladimir Skrbek
0 Likes
Absent Member.. DTilford Absent Member..
Absent Member..

Re: Pass Data from Test Plan User Field To Defect User Field

I tried to follow your code as close as possible but data is not receiving a value for the UDA.

Sub Defects_Bug_New
On Error Resume Next
Set TSRISK = TDConnection.UserSettings
TSRisk.Item = ("Scripts")
Set TestRisk = TDConnection.TestFactory.item(TsRisk.value("TS_User_07"))
Bug_Fields("BG_USER_12")= TestRisk.Item(Test_Fields("TS_USER_07").Value)
msgbox "Test Risk " & TSRisk.value
0 Likes
Knowledge Partner
Knowledge Partner

Re: Pass Data from Test Plan User Field To Defect User Field

Hi DTilford,
I think you should take the code itself.
I think the object TSRISK is the object for UserSettings and if you will see the OTA API Referenece you will see that it does not have any method or properties with name Item.

So use my code for writting values:
set uSet = TDConnection.UserSettings
uSet.Open("Scripts")
uSet.Value("CurrentModule") = "MyValue"
...
uSet.Close()

in this example the uSet is the object for UserSettings.
The Open method is for opening the category with name "Scripts". I have used this name just for my purpose, you can use your own name for the category.
The method Value is method for writing value "MyValue" to the item with name "CurrentModule" under category currently opened "Scripts".
The last method is for closing and updates of the UserSettings category.

For reading the value from user settings use this code:
set uSet = TDConnection.UserSettings
uSet.Open("Scripts")
myVariable = uSet.Value("CurrentModule")
...
uSet.Close()

In this code the Open method will open the category "Scripts".
The property Value will read the value from item with name "CurrentModuel" and save it in the variable myVariable.

Wrong code:
- this code
TSRisk.Item = ("Scripts")
is wrong it cannot works

Try to debug it. It means comment the line with On Error Goto 0 and On Error Resume Next

Note: also take into account that this works on HPQC 9.0. I did not test it under HPQC 9.2.

Best Regards
0 Likes
Absent Member.. DTilford Absent Member..
Absent Member..

Re: Pass Data from Test Plan User Field To Defect User Field

Still struggling with passing of data. As you can see this is above my current skill set.

Sub Defects_Bug_New
On Error Resume Next
set uSet = TDConnection.UserSettings
uSet.Open("Scripts")
uSet.Value("CurrentModule") = "MyValue"
Bug_Fields("BG_USER_12")= uSet.Item(Test_Fields("TS_USER_07").Value)
msgbox "Test Risk " & uSet.Item(Test_Fields("TS_USER_07").Value)
uSet.Close()
0 Likes
SreeKrishnan Absent Member.
Absent Member.

Re: Pass Data from Test Plan User Field To Defect User Field

well try this one out and see

set td = TDConnection
Set mytestfact = td.TestFactory
Set mytest = mytestfact.Item(TestSetTest_Fields.Field("TC_TEST_ID").Value)
Bug_Fields.Field("BG_USER_12").Value= mytest.Field("TS_USER_07")

0 Likes
SreeKrishnan Absent Member.
Absent Member.

Re: Pass Data from Test Plan User Field To Defect User Field

You need to put the code under Sub Defects_Bug_New.

Sub Defects_Bug_New
On Error Resume Next
Dim td
set td = TDConnection
Set mytestfact = td.TestFactory
Set mytest = mytestfact.Item(TestSetTest_Fields.Field("TC_TEST_ID").Value)
Bug_Fields.Field("BG_USER_02").Value= mytest.Field("TS_USER_01")

Set td = Nothing
On Error GoTo 0
End Sub
0 Likes
Knowledge Partner
Knowledge Partner

Re: Pass Data from Test Plan User Field To Defect User Field

I do not know if you understand my process and how the code from this thread work:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1214778

If you will see that code imagine how it works:
1) you need put the code to the Manual Runner script. This code will save the currently run test in test set and test id from this test.
uSet.Value("CurrentTestNumber") = CStr(TestSetTest_Fields.Field("TC_TEST_ID").Value)

the test id ("TC_TEST_ID") is saved to the user sattings under vategory "Scripts" and to the value with name "CurrentTestNumber".
So when you click on Run test, then the test id is saved to this user settings. I have used user settigs because it is feature of HPQC. You can save it anywhere else. Some other users use temporary file 🙂

2) when you open new defect you need read this saved value. And this script has to be in the Defects module script.
This line is for getting tst object
runTestId = uSet.Value("CurrentTestNumber")
set tdc = TDConnection
set mytestfact = tdc.TestFactory
set testObj = mytestfact.Item(runTestId)
Bug_Fields.Field("BG_USER_02").Value = testObj.Field("TS_NAME")

3) of course there are more code that you have to write so the value "CurrentTestNumber" in category "Script" is deleted in other situations.

Please write more details what does not work, also try to debug it it will tell you the error or use msgbox and you will see what is in the variables.
I cannot tell why it does not work without details what are you doing.
I use this code nearly 2 years and it works fine for me.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.