Access each Bug item after filtering and creating newlist in QC using com4j

1.1k views Asked by At

I am able to connect to hpqc using com4j and also able to filter the defect. Now i need to access each item of the buglist.

I am able to access for a single defect like :

IBug bug = bugfactory.item(55203).queryInterface(IBug.class);
System.out.println(bug.field("BG_DEV_COMMENTS"));

But i want to be able to access all defect withing a List. So this is what i did:

IBugFactory bugfactory = td.bugFactory().queryInterface(IBugFactory.class);
ITDFilter fil = bugfactory.filter().queryInterface(ITDFilter.class);
fil.filter("BG_USER_13","Not Production");
IList buglist = fil.newList();

After this, I want to access each list item, so i did

for(int i=1;i<=buglist.count();i++{
 IBug bug1 = buglist.item(i)  // this statement is not working --
}

i cannot use IBug bug1 = buglist.item(i).queryinterface(IBug.class) statement as well.

What should be the correct code to access each item of the buglist and assign that to a Bug.

1

There are 1 answers

0
pvash On

Solved it! Solution might be helpful for someone! This is what i did!

IBugFactory bugfactory = td.bugFactory().queryInterface(IBugFactory.class);
ITDFilter fil = bugfactory.filter().queryInterface(ITDFilter.class);
fil.filter("BG_USER_13","Not Production"); //any filter value
IList buglist = fil.newList();      
Iterator itr = buglist.iterator();
while(itr.hasNext()){
   Com4jObject comobj = (Com4jObject)itr.next();
   bug = comobj.queryInterface(IBug.class);
       System.out.println(bug.field("BG_BUG_ID").toString());
}

This gave ne the BugID's of all the defects within the buglist!