It's all about the answers!

Ask a question

How to get Work Item Owner name from RTC Plain Java API

Michael Plautz (26711) | asked Feb 18 '15, 2:59 p.m.
 I have been able to use the RTC Plain Java Client API to successfully connect to a repository, list all of the project areas, and then list all of the work items within a project area. 
One of the last things I am trying to figure out is how to get all of the following information:
Story/Task ID #: IWorkItem.getId()
Parent ID #: (I'm not sure how to get the links to a work item, but specifically the "Parent" link)
Story Points: ? (Is this an attribute?)
Title: IWorkItem.getHTMLSummary()
Description/Acceptance Criteria: IWorkItem.getHTMLDescription()
Owned By: IWorkItem.getOwner()
(As you can see, the Parent ID and Story Points are two that I do not know about).

Specifically, for the IWorkItem.getOwner() method, it returns an object of time IContributorHandle. When I go through the JavaDoc for IContributorHandle, I see that it is an object that only has public methods entirely inherited from the IItemHandle class. None of these methods list anything like getName() for instance. When I simply do IContributorHandle.toString(), I get a string of some of the field details, but they only include the state UUID, the item UUID, the origin, and its immutibility. 
How do I get the name of the contributor (or an object that has that info) from this IContributorHandle object?

(And of course to save me the trouble, how do I get the Parent Work Item and Story Points as well?)

Michael Plautz commented Feb 18 '15, 3:28 p.m. | edited Feb 18 '15, 3:29 p.m.

 Thanks @KevinRamer. That helps tremendously for the IContributorHandle details. 

I do not totally comprehend how to use the information on the story points. Is this something I use with IWorkItem.getValue()? Because in the JavaDoc, I do not even see a java package named, nor a class named Complexity.

Kevin Ramer commented Feb 18 '15, 4:08 p.m. | edited Feb 18 '15, 4:09 p.m.

I'm guessing that one could get the attribute by that ID, then get its value.  Story Points is one of the rare items whose value is really a value, not an identifier, ok it is an identifier, but it's a numeric string.

 I use this:

        IWorkItemClient service = getWorkItemClient();
// IProjectAreaHandle area
// String attributeId -- ""
        IAttribute attribute = service.findAttribute(area, attributeId, null);

    private IWorkItemClient getWorkItemClient() {
        return (IWorkItemClient)repository.getClientLibrary(

Michael Plautz commented Feb 18 '15, 6:30 p.m.

 It works beautifully. I wondered how the heck to do an IAttribute lookup, since none of the IAttribute methods have any lookup capabilities. 

When I do the IWorkItem.getValue(IAttribute) method using the above approach to obtain the correct IAttribute, I get an Object back that identifies itself as an ILiteral (via toString) but is actually an

@KevinRamer, if you would like to receive credit for the answer, feel free to extract out what you said and make in an answer and I'll mark it right. Otherwise I'll post an answer when I have all three - I'm still working on the links/parent work item thing.

Michael Plautz commented Feb 19 '15, 9:10 a.m.

 Also Kevin (@yzwkzfn), is the Story Points ("") attribute documented anywhere? That was very helpful but it was also the first I had ever heard of it.

Ralph Schoon commented Feb 19 '15, 9:39 a.m. | edited Feb 19 '15, 9:41 a.m.


The complexity attribute can be customized. The various templates define something e.g. the story work item type with a story points attribute in the scrum template. If you click on the story points attribute it in the work item types and attributes editor, for work item type story it shows the "" as external ID. Which one to use in planning is then configured in the planning section - you select th one - story points is preselected in scrum.

Accepted answer

permanent link
Kevin Ramer (4.5k8184200) | answered Feb 18 '15, 3:22 p.m.
I've seen this handy snippett:

        IContributor contributor = (IContributor) teamRepository.itemManager()
                .fetchCompleteItem(handle, IItemManager.DEFAULT, null);
        String userID=contributor.getUserId();

teamRepository is ITeamRepository class and you probably have one in-hand.

I'll let others chime in on the links.  Story points is an enumeration type whose id is:

Ralph Schoon selected this answer as the correct answer

One other answer

permanent link
Ralph Schoon (63.2k33646) | answered Feb 19 '15, 3:01 a.m.
I would suggest to read carefully to understand the structure better and to understand what handles are (basically a thing you can get the object) and the object itself, how to get them etc.

Ralph Schoon commented Feb 19 '15, 3:02 a.m.

With respect to IAttributes should add more info.

Ralph Schoon commented Feb 19 '15, 3:09 a.m.

Finally, you can also search that blog (and the whole internet/the site), so if you have a Java Class, you can often find related posts and examples. The search lists a couple of correct answers.

Michael Plautz commented Feb 19 '15, 9:02 a.m.

 Thank you @rschoon, this post actually helped me put things into better perspective. The answer that @KevinRamer gave did exactly what your post was talking about. It uses the teamRepository's itemManager() to fetch the complete item. This applies to the IContributor/IContributorHandle and IWorkItem/IWorkItem handle relationships. The IItemManager.DEFAULT and IItemManager.REFRESH is an important thing to know to. In my case, I am just using lookups, so I will not ever need for things to refresh, but if I were modifying and creating stories, then the refresh is important to know.

To give an in context answer for how to get the parent of a work item, given a team repository and a work item object, this is how you get the parent work item:

Michael Plautz commented Feb 19 '15, 9:06 a.m. | edited Feb 19 '15, 9:06 a.m.
final ILinkManager linkManager =
(ILinkManager) teamRepository.getClientLibrary(ILinkManager.class);
IReference workItemRef = linkManager.referenceFactory().createReferenceToItem(workItem);
ILinkQueryPage queryPage = linkManager.findLinksBySource(WorkItemLinkTypes.PARENT_WORK_ITEM, workItemRef, monitor);
java.util.Collection<ilink> links = queryPage.getAllLinksFromHereOn();
for (ILink l : links) {
    IItemHandle linkHandle = (IItemHandle) l.getTargetRef().resolve();
    if (linkHandle instanceof IWorkItemHandle) {
        IWorkItem parentItem = (IWorkItem) teamRepository.itemManager().fetchCompleteItem(linkHandle, IItemManager.DEFAULT, monitor);

Ralph Schoon commented Feb 19 '15, 9:30 a.m.

Michael, you probably want to search my blog next time around. There is a good chance that you will find code for the most common use cases, including code like the above (e.g. in ).

Good luck with your endeavors.


Ralph Schoon commented Feb 19 '15, 9:34 a.m.

Oh, and to get an (almost) complete set of API examples for almost everything with respect to work item manipulation, see the code downloadable from the linked post does most of the tricks you want to know in the

showing 5 of 6 show 1 more comments

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.