It's all about the answers!

Ask a question

How to fectch value of custom attribute of type contributor with java api?


Nilesh Patil (1734150) | asked Mar 04 '13, 9:28 a.m.
Please I need to know how to get value of a custom attribute of type Contributor list to a work item programmatically (via the Java Plain client API).
I am able to do it if the custom attribute is of type Small String:

But I need to know how to do so if the custom attribute is of type Contributor list..
Thank you so much in advance

2 answers



permanent link
sam detweiler (12.5k6195201) | answered Mar 04 '13, 10:26 a.m.
you will need to use the ContributorManager object on the repository connection to be able to get the details from the contributor objects in the list

Comments
Nilesh Patil commented Mar 04 '13, 11:54 a.m.

Hi Sam thanks for quick reply.
I am writing custom advisor. I have tried with IworkItemServer method. I am getting attribute first(Using IworkItemServer.findAtribute () method). When I used workitem.getValue(custom_Contributor_attribute_filed) it is giving meĀ  IContributorHandle of default user(i.e Unassigned) even though I have selected particular user(This field is like "Owned by" field). I am not able to get currently selected user in the custom_Contributor_attribute_filed. I tried with IworkItemServer enumeration mehtod but getting assertionFailed error(Also tried with EnumerationManager.internalresolve(...) method). Please let me know if anyone have idea to how to get value custom attribute of type contributor?


Ralph Schoon commented Mar 04 '13, 12:30 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Funny, I just realized I have no example for the server, where I resolve the contributor handle to a contributor. Hang in there, I am trying to create one.


permanent link
Ralph Schoon (63.5k33646) | answered Mar 04 '13, 12:13 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Mar 04 '13, 12:14 p.m.
Nilesh, you can find example code here: http://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ there are other posts on that blog with examples you might be interested in.

Please be aware of http://rsjazz.wordpress.com/2012/12/14/do-not-modify-the-triggering-element-in-an-operationadvisor/ should you try to modify your work item in the advisor.

Comments
Ralph Schoon commented Mar 04 '13, 12:58 p.m. | edited Mar 04 '13, 1:13 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER


The code to get an arbitrary IContributor Handle resolved to an IContributor I found is:

IContributorHandle creator = resolved.getOwner();
fRepositoryItemService=getService(IRepositoryItemService.class);

IContributor user = (IContributor) fRepositoryItemService.fetchItem(creator, IRepositoryItemService.COMPLETE);

You need to add the IRepositoryItemService to the prerequisites

<prerequisites>
    <requiredservice interface="com.ibm.team.workitem.service.IWorkItemServer"/>
    <requiredservice interface="com.ibm.team.workitem.common.IWorkItemCommon"/>
    <requiredservice interface="com.ibm.team.repository.service.IRepositoryItemService"/>
</prerequisites>


This assumes you try to write an advisor for the server. On the client the API is different and you can find code in my blog for that. It also resolves the IContributorHandle.

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.