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

How to get and update the owner of the work item via Java API?

 I can get and update some string attributes of a work item via Java API. 
copiedWorkItem is the object of IWorkItem;
 String currentSummary = copiedWorkItem.getHTMLSummary().getPlainText().trim();
            if (!currentSummary.equalsIgnoreCase(workitem.getSummary().trim())){
                IAttribute summaryAttribute= workItemClient.findAttribute(projectArea, IWorkItem.SUMMARY_PROPERTY, monitor);
                copiedWorkItem.setValue(summaryAttribute, workitem.getSummary());
            }
But I cannot get and set the value of "Owner". Who can help me? 

0 votes


Accepted answer

Permanent link
<tt>IWorkItem.getOwner()</tt> and <tt>IWorkItem.setOwner()</tt> deal with <tt>IContributorHandle</tt>, not strings.  I'm not really sure how this interacts with the <tt>OWNER_PROPERTY</tt> attribute.

Working with getOwner() would look something more like this:
IContributorHandle ownerHandle = workitem.getOwner();
//fetch the full object to see things like IContributor.getName(), IContributor.getUserId(), etc...
IContributor owner = teamRepository.itemManager().fetchCompleteItem(ownerHandle, IItemManager.DEFAULT, progressMonitor);

If you want to change the owner, use the IContributorManager to get the contributor:
IContributor newOwner = teamRepo.contributorManager().fetchContributorByUserId(newOwnerUserId, progressMonitor);
copiedWorkItem.setOwner(newOwner);


Jayee Huang selected this answer as the correct answer

0 votes

Comments
I meet a new problem, I cannot find the right API to get and update status of a work item. 
Andrew, do you know about that?


One other answer

Permanent link
Thanks Andrew. I used this in my project and it worked.
But I think it is very hard to find the correct API with clear specification.

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
× 1,722

Question asked: Mar 08 '13, 11:02 a.m.

Question was seen: 7,386 times

Last updated: Mar 11 '13, 11:15 a.m.

Confirmation Cancel Confirm