It's all about the answers!

Ask a question

In Plain Java API, how to List and create WorkItem Links and to get Owner, Project Area and Status of a WorkItem

Tiago Fernandez (5351619) | asked Aug 12 '13, 2:42 p.m.
edited Aug 12 '13, 3:20 p.m.

Hello I am doing some basic tries with Plain API, and I have some questions, that might seems fool questions since I am a beginner, anyway, here they go:  

1) How should I do to (given a workItem) list all its links (any type of link specifying the type of link it is).

2) Similar to the prior question, How should I do to create a link to a given WorkItem, the link I want to create is the type "Related Artifacts"

3) And the last question is how do I get the name of the Owner, the Project Area, and the current state of a WorkItem. For this I had tried workItem.getOwner(), but it returns " (stateId: <unset>, itemId: [UUID _9UUxMCLiEd-NDrRiecOlSQ], origin:"

4) Then which are all possible states a WorkItem can have, so then depending of its state, I will do some specific actions, in other words, how should I do a case/if statement with the WorkItem state?

Thank you very much for the help.

PS: Just to mention that part of my code that I have, is ony until I check if a WorkItem Number exists or not:


 def workItemClient = (IWorkItemClient)repo.getClientLibrary(IWorkItemClient.class)
 int workItemNumber = -1
 try {
  workItemNumber = Integer.parseInt(wi);
  println("WorkItem Number after Integer parser:" + wi)
 } catch (NumberFormatException e) {
  println("Invalid work item nubmer:" + wi)
 try {
  workItem = workItemClient.findWorkItemById(workItemNumber, IWorkItem.FULL_PROFILE, new SysoutProgressMonitor())
  println("["+workItem.getId()+"] "+workItem.getHTMLSummary().getPlainText())  
  println("Owner is: " + workItem.getOwner())
 } catch (NullPointerException e) {
  println("The specified WorkItem Number doesn't exist:" + wi)


One answer

permanent link
Rosa Naranjo (2.9k11723) | answered Aug 12 '13, 4:12 p.m.
edited Aug 12 '13, 4:12 p.m.
My colleague has written several blog posts about the Plain Java Client API.  Check out this post and others which may contain the answers to your questions.

If this helps, please mark the answer as accepted.

Michael Plautz commented Feb 18 '15, 3:22 p.m. | edited Feb 18 '15, 3:23 p.m.

 For printing the work item owner details, this can specifically be done from the second post link, in the Printing the Administrators and Team Members of a Process Area section. If you have a your IWorkItem object and your ITeamRepository object, these lines of codes do it:

IContributor contributor = (IContributor) teamRepository.itemManager()
        .fetchCompleteItem(item.getOwner(), IItemManager.DEFAULT, null);
System.out.print(": " + contributor.getUserId() + "\t"
        + contributor.getName() + "\t" + contributor.getEmailAddress() + "\t");


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.