It's all about the answers!

Ask a question

Getting the value for comments from a ResolvedWorkItem?


Roger Dunn (1654) | asked Apr 26 '11, 12:45 p.m.
My code obtains the value for various attributes from a ResolvedWorkItem, based on their respective attribute ids. The following logic generally works fine:

WorkItemUIWorkingCopy uiCopy = (WorkItemUIWorkingCopy) myWorkItemWorkingCopy.getAdapter(IWorkItemUIWorkingCopy.class);

ResolvedWorkItem workItem = uiCopy.getResolvedWorkItem();
Object o = workItem.getValue(someAttributeIdentifier);


However, getValue() throws an exception if the attribute id is "internalComments" (the id for the comments field):

org.eclipse.core.runtime.AssertionFailedException: assertion failed:
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
at com.ibm.team.workitem.client.internal.util.ResolvedWorkItem.getValue(ResolvedWorkItem.java:181)

I've confirmed that the attribute exists within the work item (that is, workItem.findAttribute("internalComments") returns a non-null result, and calling getAttributeType on it returns the value "comments"). What is the right way to get the value for the comments?

Thanks!

Roger

One answer



permanent link
Megan Katysovas (7665) | answered Jun 13 '11, 3:15 p.m.
There is a get specific to comments -

IComment[] comments = iWorkItem.getComments().getContents();


From there you can get the creator / data / description of each comment.

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.