Re: HP ALM 11.00 ota api - no idea :( (1027 Views)
Reply
Occasional Advisor
djuentgen
Posts: 10
Registered: ‎03-13-2014
Message 1 of 13 (1,083 Views)

HP ALM 11.00 ota api - no idea :(

[ Edited ]

Hey together,

 

got some trouble while trying to use ota api. can anyone assit me maybe with some tips how to use the ota api?

i think i dont understand how to use or access it.

 

I'm trying to set a default value to a field that i added to the testconfiguration mask triggered by the creation of the test in in the testplan.

 

so please dont laugh ;) i put the code in the Sub Test_AfterPost Workflow :)

 

i tried somthing like that:

set TdcTestConfFact = TDConnection.TestConfigFactory
set TestConf = TdcTestConfFact.Field("TSC_STATUS_01")
set TestConf="HOCH"

 

 or

 

set TdcTestConfFact = TDConnection.TestConfigFactory
set TestConf = TdcTestConfFact.Field
set TestConf("TSC_USER_01")="HOCH"

 

 

and lot of other combinations which all seems to be very wrong :D

 

maybe someone can help me :)

 

my target is to fetch the priority value of the test and assign it to the priorityfield(TSC_USER_01) which i added to testconfigurations mask after creating the test, triggered by the creation. so that the first testconfiguration in the list hast the same priority as the test itselfs. for every new configuration which will be created the priorityfield ist mandatory and has to be filled out, but for the first configuration which is created by default there is no value in my field tsc_user_01 :/

 

thanks so much for helping me, giving advices or assitance in advance 

-daniel

Please use plain text.
Honored Contributor
Trudy Claspill
Posts: 3,548
Registered: ‎09-09-2010
Message 2 of 13 (1,049 Views)

Re: HP ALM 11.00 ota api - no idea :(

[ Edited ]

I'm a big advocate of learn-by-doing, so I'm not going to give you the code outright, but I will try to steer you towards some help.

 

I suggest that you start by looking at the Examples directory in the API help file, specifically at the Planning Tests Code Samples > Finding Tests and Test Folders Code Samples. Those examples aren't for Test Configurations specifically but can help you become familiar with the general concepts of how to use Factory objects and Filters to find specific entities. In general you
- establish a connection
- instantiate a factory
- define a filter for what you want to find
- use the NewList method of the factory to retrieve the entities you want, using the filter criteria you defined.

Since you are trying to do this in workflow code, you should also look in the Administrator Guide and the Workflow Examples chapter. Specifically look at the example "Example: Copying Field Values to Another Object". Again the example doesn't deal specifically with the Test Config entity, but it will give you the general concepts of manipulating an out-of-context entity through the workflows.

 

After you've looked those documents over, come back to forum with questions.

[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
Please use plain text.
Occasional Advisor
djuentgen
Posts: 10
Registered: ‎03-13-2014
Message 3 of 13 (1,038 Views)

Re: HP ALM 11.00 ota api - no idea :(

Hello Trudy

 

thanks for spending all the time for helping me.

 

i tried this morning a bit but i dont get any approach to fetch any data by ota api :/ actual i think i'm a bit to stupid to use ota api :D

 

establishing a connection and instantiating a factory will be don like this way i think :

 

  set TDC = TDConnection
  set TSCFact = TDC.TestConfigFactory

 but setting filters or using the NewList Method ist not clear to me at all :/

tried a few possibilities but nothin worked. tried with msgboxes do become something to screen but most of the time no msgbox popped off or if it comes it was emtpy..

 

  set TSCFilter = TSCFact.Filter
  TSCFilter(FieldName)="TSC_USER_01"

 

or

  set TSCfgList = TSCFact.NewList(TestConfiguration_Fields.Field("TSC_USER_01"))

 

am i completly on the wrong track? it cant be that difficult :(

 

is it possible to activate a debugging mode or something like that? i dont know form where i should get any information why that crap didnt work.. :(  i'm poking around in the dark

 

i tried to apply the

Example: Copying Field Values to Another Object to my problem but nothing happens.

is it right to use  TestConfigurationFactory or have i to use TestFactory and filter out the COnfigurationsfields from the test?

 

thankz

Please use plain text.
Honored Contributor
Trudy Claspill
Posts: 3,548
Registered: ‎09-09-2010
Message 4 of 13 (1,027 Views)

Re: HP ALM 11.00 ota api - no idea :(

This is going to take a while :)

 

Let's start by saying this code is in the Test_AfterPost subroutine.

 

Whenever I'm modifying workflow code, I always comment out the On Error statements.  If an exception is raised the On Error statements would cause processing to ignore the error and try to execute the next line. I comment them out so that I will actually see the error messages.

 

 

Sub Test_AfterPost
'  On Error Resume Next

'  On Error GoTo 0
End Sub

 The first step in getting data about entities that are out of context is to get a variable pointing to the Factory for that entity.

 

Sub Test_AfterPost
    dim TestConfigFact

'  On Error Resume Next

  set TestConfigFact = TDConnection.TestConfigFactory

'  On Error GoTo 0
End Sub

 The next step is to get a variable pointing to the Filter object for that factory. The filter will be used to specify what you want to retrieve.

Sub Test_AfterPost
    dim TestConfigFact
    dim TCFFilter

'  On Error Resume Next

  set TestConfigFact = TDConnection.TestConfigFactory
  set TCFFilter = TestConfigFact.Filter

'  On Error GoTo 0
End Sub

 The next step is to set the filter for retrieving items. In your case, you need to get all the Test Configurations associated to the Test you just created.  You set filters using the data fields of the entity you are retrieving. So, you would look in the Database Reference at the table for Test Configurations to see what fields are available.  In this case, the Test Configuration table includes the field TSC_TEST_ID, which contains the ID for the Test Case to which the Test Configuration is linked.  Since we are in the Test workflow, we have access to the information about the current Test Case, to the Test Case ID is a good choice for the filter.

 

To set a filter, put the field name on the left side of the equation, and the value you want to use on the right side.

 

Sub Test_AfterPost
    dim TestConfigFact
    dim TCFFilter

'  On Error Resume Next

  set TestConfigFact = TDConnection.TestConfigFactory
  set TCFFilter = TestConfigFact.Filter
  TCFFilter.Filter("TSC_TEST_ID")=Test_Fields("TS_TEST_ID").Value

'  On Error GoTo 0

End Sub

 Then you need the command to actually retrieve the data.  That is the NewList method for the Factory object. If you have defined a Filter for the same Factory object, then when you use the NewList command that filter will automatically be used.

Sub Test_AfterPost
    dim TestConfigFact
    dim TCFFilter
    dim TestConfigList

'  On Error Resume Next

  set TestConfigFact = TDConnection.TestConfigFactory
  set TCFFilter = TestConfigFact.Filter
  TCFFilter.Filter("TSC_TEST_ID")=Test_Fields("TS_TEST_ID").Value
  set TestConfigList = TCFFilter.NewList

'  On Error GoTo 0
End Sub

 Now TestConfigList points to a list/collection of Test Configuration entities that matched the retrieval criteria (the Filter). Reference the Test Configuration object in the OTA API to see what properties and methods you have access to.

 

You want to always confirm that you actually got some records back.

Sub Test_AfterPost
    dim TestConfigFact
    dim TCFFilter
    dim TestConfigList

'  On Error Resume Next

  set TestConfigFact = TDConnection.TestConfigFactory
  set TCFFilter = TestConfigFact.Filter
  TCFFilter.Filter("TSC_TEST_ID")=Test_Fields("TS_TEST_ID").Value
  set TestConfigList = TCFFilter.NewList

  if TestConfigList.Count > 0 then
    msgbox (TestConfigList.Count)
  end if

'  On Error GoTo 0
End Sub

 

Now, in your case, you want to make an update only to the first Test Configuration that is created, right after a new test is created. But Test_AfterPost will run every time a Test Case is updated. So you need to find a way to make sure it is only updating the first configuration, and only when that new Test Configuration field is blank. In this case there should be only one Test Configuration, so maybe you want to use a line of code like this.

Sub Test_AfterPost
    dim TestConfigFact
    dim TCFFilter
    dim TestConfigList

'  On Error Resume Next

  set TestConfigFact = TDConnection.TestConfigFactory
  set TCFFilter = TestConfigFact.Filter
  ' Set filter to retrieve Test Configs for the current test case
  TCFFilter.Filter("TSC_TEST_ID")=Test_Fields("TS_TEST_ID").Value
  ' Retrieve the data
  set TestConfigList = TCFFilter.NewList

  if TestConfigList.Count = 1 then
     ' Only one Test Configuration associated with the Test
     ' Do stuff with the one Test Configuration object.
  end if

  Set TestConfigList = nothing
  set TCFFilter = nothing
  set TestConfigFact = nothing
'  On Error GoTo 0
End Sub

 

Now that you are sure you have just one Test Configuration, maybe you want to check to make sure your custom field is blank.

 

Sub Test_AfterPost
    dim TestConfigFact
    dim TCFFilter
    dim TestConfigList

'  On Error Resume Next

  set TestConfigFact = TDConnection.TestConfigFactory
  set TCFFilter = TestConfigFact.Filter
  ' Set filter to retrieve Test Configs for the current test case
  TCFFilter.Filter("TSC_TEST_ID")=Test_Fields("TS_TEST_ID").Value
  ' Retrieve the data
  set TestConfigList = TCFFilter.NewList

  if TestConfigList.Count = 1 then
     ' Only one Test Configuration associated with the Test
    if len(TestConfigList.Item(1).Field("TSC_USER_01")) = 0 then
       ' custom field has no value.
       msgbox ("Custom Test Config field has no value")
       ' Set the value on the custom field.
       ' Use TestConfigList.Item(1).Post to save the change to the Test Config
    end if
  end if

  Set TestConfigList = nothing
  set TCFFilter = nothing
  set TestConfigFact = nothing
'  On Error GoTo 0
End Sub

 Okay, that's quite a bit of code I've given you. See what you can do with it from here.

 

 

 

[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
Please use plain text.
Occasional Advisor
djuentgen
Posts: 10
Registered: ‎03-13-2014
Message 5 of 13 (1,016 Views)

Re: HP ALM 11.00 ota api - no idea :(

[ Edited ]

Good Mornin Trudy,

 

thank you so much, i've to understand first all u wrote down to me...thanks for taking all that time for helping me :)

 

after i got that - hopefully -i place a new comment with maybe new questions :D, but i want to thank u before i get startet :D

 

<3

 

 

ps: i commented the on error parts out but, i never got any error exceptions :(

 

Please use plain text.
Occasional Advisor
djuentgen
Posts: 10
Registered: ‎03-13-2014
Message 6 of 13 (1,004 Views)

Re: HP ALM 11.00 ota api - no idea :(

Hey Trudy,

 

so im back and tried, worked with the code u gave me.

The last hours i tried to fill my customfield with my defined default value but.. something worked not as i want it to :D

 

i write out my tries would you maybe look at them and show me my mistake :)?

 

thank you so much... thought it would be easy with the code u gave me but i  was wrong :D

 

Sub Test_AfterPost
    'On Error Resume Next
    Dim TestConfigFact
    Dim TCFFilter
    Dim TestConfigList
    Dim TCAdditem
    Dim TCAdditem1
    Dim TCAdditem2
    Dim TCAdditem3

    Set TestConfigFact = TDConnection.TestConfigFactory
    Set TCFFilter = TestConfigFact.Filter
    TCFFilter.Filter("TSC_TEST_ID")=Test_Fields.Field("TS_TEST_ID").Value
    Set TestConfigList= TCFFilter.NewList


    if TestConfigList.Count = 1 then
     ' Only one Test Configuration associated with the Test
       if len(TestConfigList.Item(1).Field("TSC_USER_01")) = 0 then
' custom field has no value.

          'set TCAdditem1= TestConfigFact.Additem(Null)
          'TCAdditem1.TestConfigList.Field("TSC_USER_01").Value = "Hoch"
          'TCAdditem1.TestConfigList.Item(1).Field("TSC_USER_01").Value = "Hoch"

          'set TCAdditem2 = TestConfigFact.Additem(Null)
          'TCAdditem2.TestConfigList.Item(1).Field("TSC_USER_01").Value = "Mittel"

          'set TCAdditem3=TestConfigList.Item(1).Additem(Null)
          'TCAdditem3.Field("TSC_USER_01").Value = "Niedrig"
          'TCAdditem3.Field("TSC_USER_01")="Niedrig"

          'TestConfigList.Item(1).Field("TSC_USER_01").Value= "Mittel"

          'TestConfigList.Item(1).Field("TSC_USER_01") = "Hoch"

          'set TCAdditem = TestConfigList.Item(1).Field("TSC_USER_01").Additem(Null)
          'TCAdditem.value = "Niedrig"
          'TCAdditem = "Niedrig"

' Set the value on the custom field.
' Use TestConfigList.Item(1).Post to save the change to the Test Config
       'TCAdditem.Post
       'TCAdditem1.Post
       'TCAdditem2.Post
       'TCAdditem3.Post
      'TestConfigList.Item(1).Post
       end if
    end if

     Set TestConfigList = nothing
    set TCFFilter = nothing
    set TestConfigFact = nothing

    'On Error GoTo 0
End Sub

 i tried out a line of code and if it did not worked i commented it out ;D

 

i am despairing.. :/

Please use plain text.
Honored Contributor
Trudy Claspill
Posts: 3,548
Registered: ‎09-09-2010
Message 7 of 13 (987 Views)

Re: HP ALM 11.00 ota api - no idea :(

The reason this doesn't work

          'set TCAdditem1= TestConfigFact.Additem(Null)
          'TCAdditem1.TestConfigList.Field("TSC_USER_01").Value = "Hoch"
          'TCAdditem1.TestConfigList.Item(1).Field("TSC_USER_01").Value = "Hoch"

 Is because the AddItem method is used to create a whole new entity - in this case a whole new Test Configuration entity. You don't want to do that. You want to modify the Test Configuration that already exists.

 

That is the same reason your second try didn't work.

          'set TCAdditem2 = TestConfigFact.Additem(Null)
          'TCAdditem2.TestConfigList.Item(1).Field("TSC_USER_01").Value = "Mittel"

 

Your third try has a similar reason for not working, though in this case you tried to add a new item to your list.

          'set TCAdditem3=TestConfigList.Item(1).Additem(Null)
          'TCAdditem3.Field("TSC_USER_01").Value = "Niedrig"
          'TCAdditem3.Field("TSC_USER_01")="Niedrig"

 

Your last try - AddItem is not something you can do to a Field.

          'set TCAdditem = TestConfigList.Item(1).Field("TSC_USER_01").Additem(Null)
          'TCAdditem.value = "Niedrig"
          'TCAdditem = "Niedrig"

 

Using one of these lines, plus the Post method, should've worked.

          'TestConfigList.Item(1).Field("TSC_USER_01").Value= "Mittel"

          'TestConfigList.Item(1).Field("TSC_USER_01") = "Hoch"

          'TestConfigList.Item(1).Post

 

I tried them myself and they didn't work for me either. I'll have to take more time to try to figure out why.

[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
Please use plain text.
Honored Contributor
Trudy Claspill
Posts: 3,548
Registered: ‎09-09-2010
Message 8 of 13 (982 Views)

Re: HP ALM 11.00 ota api - no idea :(

[ Edited ]

The following code works in my ALM 11.52 project. If it doesn't work in your project, tell us what version of the product you are working with and what error you are getting.

 

Sub Test_AfterPost
  dim TestConfigFact
  dim TCFFilter
  dim TestConfigList

  ' On Error Resume Next

  set TestConfigFact = TDConnection.TestConfigFactory
  set TCFFilter = TestConfigFact.Filter
  ' Set filter to retrieve Test Configs for the current test case
  TCFFilter.Filter("TSC_TEST_ID") = Test_Fields("TS_TEST_ID").Value
  ' Retrieve the data
  set TestConfigList = TCFFilter.NewList

  ' TestConfigList now points to a list of Test Configuration entities
  ' To get to a specific entity in the list use
  ' TestConfigList.Item(<index>)
  ' TestConfigList.Item(1) is a pointer to the first Test Configuration in the list. It is the same as a Test Configuration object from the OTA API.

  ' Check how many test configurations are in the list
  if TestConfigList.Count = 1 then
    ' Only one Test Configuration associated with the current Test
    
    ' Check if the custom field already has a value if len(TestConfigList.Item(1).Field("TSC_USER_01")) = 0 then ' The length of the string in the field is 0, therefore the field is empty
' Set the value in the custom field TestConfigList.Item(1).Field("TSC_USER_01") = "my_string"
' Use TestConfigList.Item(1).Post to save the change to the Test Config TestConfigList.Item(1).Post end if end if Set TestConfigList = nothing Set TCFFilter = nothing Set TestConfigFact = nothing ' On Error GoTo 0 End Sub

 

[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
Please use plain text.
Occasional Advisor
djuentgen
Posts: 10
Registered: ‎03-13-2014
Message 9 of 13 (936 Views)

Re: HP ALM 11.00 ota api - no idea :(

Helly Trudy,

 

thank u so much 4 giving me so much advices. Sorry for not replying the last week, but i was on holiday ;D and have to go on this week. i'll try ur code and give you feedback later.

 

thanks and greetzs

daniel

Please use plain text.
Occasional Advisor
djuentgen
Posts: 10
Registered: ‎03-13-2014
Message 10 of 13 (907 Views)

Re: HP ALM 11.00 ota api - no idea :(

[ Edited ]

Hello trudy,

 

gott verdammte scheiße :( es klappt einfach nicht! so! sorry for that :D

 

sorry for not answering, but i was in trouble the last days.

today i tried the code in my hp alm project but.. it doesnt work :(

dont know whats wrong or where i should get errors. i dont get any errors while using hp alm

my versoin which i use is HP ALM 11.00

 

i saw that in the following line the zero is an o and changed it... hoping it will help but

      ' Set the value in the custom field
      TestConfigList.Item(1).Field("TSC_USER_O1") = "my_string" 

 if i add a new test in my testplan and switch to test Configs the Fields are not filled out :(

 it looks like: see attached pic :)

 

thanks for helping me

 

greetz daniel

Please use plain text.
Honored Contributor
Trudy Claspill
Posts: 3,548
Registered: ‎09-09-2010
Message 11 of 13 (896 Views)

Re: HP ALM 11.00 ota api - no idea :(

Double check the customization you did to create the fields and confirm that the underlying field name is actually TSC_USER_01. Also what is the Type of that custom field?

That "o" would've definitely caused a problem. Good catch! That must've happened when I pasted the code.

What is the patch level on your system? To find out go to Help > About > Additional Information. If you aren't up to patch 17, which is the latest, you might want to update your system.

You could try putting some Message Box statements into the code to confirm that it is executing the expected path.

How are you creating the test cases? Do you click the New Test button or use some other method?

What is the Type of the test case - Manual?

The code definitely works on ALM 11.52 patch 02. I can't think of a reason why it wouldn't work on 11.0.
[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
Please use plain text.
Occasional Advisor
djuentgen
Posts: 10
Registered: ‎03-13-2014
Message 12 of 13 (856 Views)

Re: HP ALM 11.00 ota api - no idea :(

Helly trudy,

 

sorry for replying so late, but i was ill last week.

so the Fieldname is TSC_USER_01 the type of the Field is "Lookup List". I've defined a list, and the word which i want to fill in as default is placed on the list,too.

The HPQC system is on patchlevel 09 but i have no influence to the patchlevel or possibilities to force an update.

the way i create tests is by clicking on the "new Test button" in the taskbar or shortcut "ctrl+n"

 

thanks a lot

Please use plain text.
Honored Contributor
Trudy Claspill
Posts: 3,548
Registered: ‎09-09-2010
Message 13 of 13 (823 Views)

Re: HP ALM 11.00 ota api - no idea :(

Unfortunately I can't provide any additional help. Even when I define the field TSC_USER_01 as a lookup list and use a value from that list, the code still works in my environment.

I don't have an ALM 11.0 environment where I could try to debug it further.

My only recommendation is to request that your administration team get the server updated to the current patch level. Maybe there is a corrected defect in the product that will resolve your issue.
[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation