It's all about the answers!

Ask a question

WI queries and Results question

Sergio Lorente (981711) | asked Dec 27 '11, 9:36 a.m.

I have some questions about the way to get values from a WI.

I customize a WI and i'm trying to do some queries.

After this point:

IQueryResult<IResolvedResult<IWorkItem>> result = queryService.getResolvedExpressionResults(prjAreaHandle, term2, IWorkItem.FULL_PROFILE);

while (result.hasNext(null)){
IWorkItem myWI =;
MyIWorkItem custom = new MyIWorkItem(myWI);

****I have a Class (MyIWorkItem) which contains several attributes:
id, appname, owner, etc. I found several values but i still looking for some others.

Is it supposed that "IWorkItem.FULL_PROFILE" above in the method brings all the record for every WI in the result?

Does exists some methods as findAttributeValue(String AttributeName) or similar??? How can i find those values then??

Thanks in advance

2 answers

permanent link
Eduardo Bello (4401821) | answered Dec 27 '11, 1:20 p.m.

First, "IWorkItem.FULL_PROFILE" is used to bring all attributes from an WorkItem.


Second, there is the method Object getValue(IAttribute attribute), but you need to get an IAttribute object. So, you can use a method like this one:

public Object findAttributeValue(IWorkItem workItem, String attrId) {
IWorkItemServer workItemServer = getService(IWorkItemServer.class);
IAttribute attribute;
try {
attribute = workItemServer.findAttribute(workItem.getProjectArea(), attrId, null);
if ((attribute!=null) && (workItem.hasAttribute(attribute))) {
return workItem.getValue(attribute);
} catch (TeamRepositoryException e) {
return null;
return null;

Note that this code works on server side. If you want to use at client side you must access the findAttribute method from IWorkItemClient

permanent link
Sergio Lorente (981711) | answered Dec 28 '11, 9:33 a.m.
Hi Eduardo,

I learned a lot of things reading your plug-ins posts a few weeks ago. They are really interesting.

Thanks for your answer.

I used the IWorkItemClient as you suggested and it works very good.

Now i have a similar problem:

In my WI there is a link to the build. In this build, ( IBuildResult object)
I cannot found the person who made the Request.

And i have the same problem with the IBuildDefinitionInstance object and the "Project or Team Area" field.

I have something like this:

if(endPointDesc.getId().equalsIgnoreCase("")) {
for (int i=0; i < refList.size(); i++) {
try {
IBuildResult buildResultWI =
(IBuildResult) teamRepository.itemManager().fetchCompleteItem(
(BuildResultHandleImpl) refList.get(i).resolve(), ItemManager.DEFAULT, monitor);
IBuildRequestHandle requestHandle =
(IBuildRequestHandle) buildResultWI.getBuildRequests().get(0);
IBuildRequest request =
(IBuildRequest) teamRepository.itemManager().fetchCompleteItem(requestHandle,
IItemManager.DEFAULT, null);
System.out.println("Label:"+buildResultWI.getLabel()+ "------" +
catch (ItemNotFoundException e)
} // end for"included in builds..." + refList.size());

Thanks for your help.

Your answer

Register or to post your answer.