workitem getOwner
For example I got a code like this: (this code does not work, it is not returning a string)
public String getOwner(IWorkItem workItem) {
return workItem.getOwner();
}
So I want the content of the owner-attribute (= string) for a given workitem.
getOwner() returns a IContributorHandle. But what can I do with this handle?
public String getOwner(IWorkItem workItem) {
return workItem.getOwner();
}
getOwner() returns a IContributorHandle. But what can I do with this handle?
Accepted answer
Something like this should work:
IContributorHandle conHandle = wi.getOwner();
ITeamRepository repo = (ITeamRepository) conHandle.getOrigin();
IContributor contrib = (IContributor) repo.itemManager()
.fetchCompleteItem(conHandle, IItemManager.DEFAULT, null);
contrib.getName();
contrib.getUserId();
Comments
"ITeamRepository" is the object of client side.
When I develop a plug-in/advisor in the server side, it will always be "null".
What should I do in the server side?
See http://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/ for example. You basically use the service.
One other answer
Something like this should work:
IContributorHandle conHandle = wi.getOwner();
ITeamRepository repo = (ITeamRepository) conHandle.getOrigin();
IContributor contrib = (IContributor) repo.itemManager()
.fetchCompleteItem(conHandle, IItemManager.DEFAULT, null);
contrib.getName();
contrib.getUserId();
That works perfectly although I used IContributorHandle[] contributors = projectArea.getMembers(); to get the list of members then looped through them using them as the conHandle to find the user I wanted form those in the project area, words cannot describe how useful this was.