//Here I got a null "discussionAttribute"?
Attribute discussionAttribute = service.findAttribute(projectArea, "discussion", monitor);
I suspect "discussion
" isn't a valid WorkItem attribute id.
Try the question "Where can I find a list of IWorkItem
attributes" to query all the attributes of the work item, in order to get the correct attribute name for "discussion
" (maybe "comments
"?)
Use
IItemManager.fetchCompleteItem
to fetch the item for any handle.
The items carry the actual info; the handles are essentially just like pointers / URLs.For example:
IContributorHandle contributorHandle = ...
IContributor contributor = (IContributor) teamRepository.itemManager.fetchCompleteItem(contributorHandle, IItemManager.DEFAULT, null); // should really provide a progress monitor in last arg for progress / cancelaton
String name = contributor.getName();
That's for client-side. For server-side, use IRepositoryItemService to fetch the item.
In the attributes of the project area configuration, I see
"Comments": ID "com.ibm.team.workitem.attribute.comments", but no "discussion".
On Jazz.net, you find a link to this discussion and mentions an id named "internalComments
".
Try then:
Attribute discussionAttribute =
service.findAttribute(projectArea, "internalComments", monitor);
Don't forget to save your modified Work Item though, as in "Modify a WorkItem"
IDetailedStatus s = wc.save(null);
if (!s.isOK()) {
throw new TeamRepositoryException("Error saving work item",
s.getException());
}