Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Getting the state of the child workitem

I have created two workitems, Project (parent) and ChangeRequest
(child).
I want to have precondition for saving state of parent workitem.
The precondition is "Parent workitem will be saved at "development completed" state only if all of its changerequests's(child) workitems state is "development completed"."

Progress :
1. Able to get current state of the parent workitem
2. Able to linked workitem

Obstacles
1. Not able to resolve if there are multiple number of child WI's
2. How to get simple reference to individual child WI
3. How to get state of child WI

0 votes


Accepted answer

Permanent link

Hi Dnyanesh, It does work...you're probably missing the definitions in the plugin.xml (in this case, you definitely need the highlighted ones). You'll have to hand-code this in to the plugin.xml - page 59 of the extensions lab doc (v3.0.1) explains.

(btw. see also Nick's comment in here https://jazz.net/forum/questions/70215/fetching-parent-workitem-using-plain-java-api?redirect=%2Fforum%2Fquestions%2F70215%2Ffetching-parent-workitem-using-plain-java-api for a better way to get the work item referenced)

<prerequisites>

<requiredService

interface="com.ibm.team.workitem.service.IWorkItemServer">

</requiredService>

<requiredService

interface="com.ibm.team.build.internal.common.ITeamBuildService">

</requiredService>

<requiredService

interface="com.ibm.team.build.internal.common.ITeamBuildRequestService">

</requiredService>

<requiredService

interface="com.ibm.team.repository.service.IRepositoryItemService">

</requiredService>

<requiredService

interface="com.ibm.team.links.common.service.ILinkService">

</requiredService>

</prerequisites>

Dnyanesh Markad selected this answer as the correct answer

0 votes


3 other answers

Permanent link
Hi,

I would suggest with reading this post http://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ and then work through the rest of the posts for open questions.

You can also search the forum for API, I think I remember having seen numerous questions and answers with example code around the topics you ask about. 

0 votes


Permanent link

IWorkItemServer workItemService = getService(IWorkItemServer.class);

List<IWorkItem> children = new ArrayList<IWorkItem>();

List<IReference> references= saveParameter.getNewReferences().getReferences(WorkItemEndPoints.CHILD_WORK_ITEMS);

for (IReference reference: references){

String comment = reference.getComment();

String workItemID = comment.substring(0, comment.indexOf(":"));

IWorkItem workItem = workItemService.findWorkItemById(Integer.parseInt(workItemID), IWorkItem.FULL_PROFILE, monitor);

if (workItem.getWorkItemType().equals(requiredWorkitemType)){

children.add(workItem);

}

}

0 votes

Comments

Hi Sola,


I have tried your code. i got an error like this
"Exception checking precondition. An unhandled exception occurred during "Get link State 1".
The service 'ncb_3.GetLink@3da83da8' failed to find the required service 'interface com.ibm.team.workitem.service.IWorkItemServer'. Check <prerequisites> in plugin.xml." 


Permanent link
Dnyanesh, please follow https://jazz.net/library/article/1000 carefully. You got that exception because you did not include com.ibm.team.workitem.service.IWorkItemServer in the prerequisites. You have to manually add them in the plugin.xml like below:

prerequisites in plugin


0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,952

Question asked: Nov 16 '12, 3:55 a.m.

Question was seen: 7,214 times

Last updated: Nov 19 '12, 5:10 a.m.

Confirmation Cancel Confirm