It's all about the answers!

Ask a question

How to fetch work item parent?


pugazhenthi samidurai (26423742) | asked Apr 30 '12, 1:16 a.m.
Hi,

i have developed the java client code for fetching all available work items. Its working fine.

i am having one doubt on this.

How to fetch work item parent to the each work item.


Thanks

Pugazh

One answer



permanent link
sam detweiler (12.5k6185201) | answered Apr 30 '12, 8:39 a.m.
Given a workitem, you would search its references for 'Parent' links,
and use the handle of the workitem on the other end of the parent link.

here is how I do it for Dependancies.. (in an OperationAdvisor)

IWorkItemReferences iwr = ((ISaveParameter) data).getNewReferences();
// and only the depends on links
List<IReference> wir = iwr.getReferences(WorkItemEndPoints.DEPENDS_ON_WORK_ITEM);
// loop thru the workitems this one depends on
for(int j=0;wir!=null && j<wir.size();j++)
{
if(Debug) System.out.println("looping thru references");
// if this is to an item.. should always be
if(wir.get(j).isItemReference())
{
// get the item, and it SHOULD always be a workitem
IWorkItem r = iac.resolveAuditable(
(IWorkItemHandle)wir.get(j).
resolve(),IWorkItem.FULL_PROFILE, null);

Your answer


Register or to post your answer.