It's all about the answers!

Ask a question

IRepositoryItemService.fetchItem()


HuaXiao Jiang (434) | asked Feb 15 '23, 6:22 a.m.

for example:

IAttribute attrNew =ctx.getWorkItemServer().findAttribute(projArea, "XXX", null);
XXX is type of Contributor,
IContributor contNew = (IContributor)ctx.repositoryItemService.fetchItem(attrNew, null):null;

cause:com.ibm.team.workitem.common.internal.model.impl.AttributeImpl incompatible with com.ibm.team.repository.common.IContributor。
How do I handle IAttribute attrNew correctly to get the email address??

Accepted answer


permanent link
Ralph Schoon (63.3k33646) | answered Feb 15 '23, 6:37 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Feb 15 '23, 6:44 a.m.

The quality of the question is poor and there is no context about what this is all about. I would suggest you try to get better. 


attrNew is a work item attribute for values that are of type contributor. Its type is IAttribute - as you can see. You can not cast it to IContributor. 

You have to first get the value workitem.getValue(attrNew) of the attribute from the work item, which will be an IContributorHandle, which you have to then resolve/fetch to an IContributor to access details.

See: https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ and other posts on that blog for details.  

Ralph Schoon selected this answer as the correct answer

Comments
Ralph Schoon commented Feb 15 '23, 6:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

You should not use IWorkitemServer unless you work on a server extension. This class is not availabl ein the client API.  


HuaXiao Jiang commented Feb 16 '23, 7:43 p.m.

Ok, thank you, later the solution was found 


Ralph Schoon commented Feb 17 '23, 2:37 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Then write an answer with the solution please, or accept the answer as a solution. 

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.