It's all about the answers!

Ask a question

How Can I get childworkitems ,its type and current state from references.

Kaushik Bhalerao (611810) | asked Nov 19 '12, 1:56 a.m.
edited Nov 19 '12, 2:08 a.m.
  1. I can get type and current state of the parent workitem.
  2. I want to fetch its child workitems and its type and its current state.
  3. and want to put condition by checking the states of parent and child.
  4. I used operation advisor for this.
  5. (I referred other forums too ,which are related to the child workitems but didn't t get help.  )

I got the child references. I tried following code.

Object data = operation.getOperationData();        
                                  // The action is save
        if (data instanceof ISaveParameter)
 {             // Get state of auditable item
           ISaveParameter saveParameter = (ISaveParameter) data;            IAuditable auditable = saveParameter.getNewState();           
            // If everything is correct, the auditable is an WorkItem     if (auditable instanceof IWorkItem)
                IWorkItem parentWorkItem = (IWorkItem) auditable;

                //Getting WorkItem service
IWorkItemServer workItemServer = getService(IWorkItemServer.class);
IWorkItemReferences references = workItemServer.resolveWorkItemReferences(parentWorkItem, null);
List<IReference> listChildReferences = references.getReferences(WorkItemEndPoints.CHILD_WORK_ITEMS);
for (Iterator iterator = listChildReferences.iterator(); iterator                         .hasNext();
{                     IReference childReference = (IReference);                    
                    ILink link = childReference.getLink();

Please give me your valuable suggestion to achieve my task. 

Accepted answer

permanent link
Ralph Schoon (63.3k33646) | answered Nov 19 '12, 8:34 a.m.

I would suggest to read carefully and maybe because it talks about similar items.

You need to use this.getService() to get services in participants and advisors.

        IRepositoryItemService reposervice = getService(IRepositoryItemService.class);

Should get it. You probably have to add it to the prerequisites in the plugin.xml too. See the post mentioned above to understand what a prerequisite is.
Kaushik Bhalerao selected this answer as the correct answer

Kaushik Bhalerao commented Nov 20 '12, 7:39 a.m.

Thanks Ralph.
Second Link is very Useful.

One other answer

permanent link
Muthukumar C (32712833) | answered Nov 19 '12, 5:20 a.m.
edited Nov 19 '12, 5:21 a.m.

IWorkItemHandle ChildWIHandle = (IWorkItemHandle) childReference.resolve();
if(ChildWIHandle != null){
       ChildWorkItem = (IWorkItem) repositoryItemService.fetchItem(ChildWIHandle ,IRepositoryItemService.COMPLETE);


With this Child Workitem, you can get the Type and ID details.

Kaushik Bhalerao commented Nov 19 '12, 7:28 a.m.

Hi Muthukumar
Its very Helpful.
can you give me some details like....

In above code
What exactly I am getting in "ChildWIHandle "  and in "ChildWorkItem" ?
what is the type of "ChildWorkItem".


Kaushik Bhalerao commented Nov 19 '12, 8:23 a.m. | edited Nov 19 '12, 8:32 a.m.

Also am not getting "repositoryItemService" .

ERROR is "Cannot make a static reference to the non-static method fetchItem(IItemHandle, String[]) from the type RepositoryItemService"

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.