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

How to display value of custom attribute by running query programmatically(Java Client API)

 Hi All, 
I want to display value of custom attribute by running query programatically using java client API

IQueryableAttribute attributecust=findAttribute(projectArea, auditableClient, attributeId, null);
AttributeExpression attributecustexpre=new AttributeExpression(attributecust,AttributeOperation.EXISTS,projectArea);

IQueryableAttribute projectAreaAttribute2=findAttribute(projectArea, auditableClient, IWorkItem.PROJECT_AREA_PROPERTY, null);
AttributeExpression projectAreaExpression2=new AttributeExpression(projectAreaAttribute2,AttributeOperation.EQUALS, projectArea);

Term term= new Term(Operator.AND);
term.add(projectAreaExpression2);
term.add(attributecustexpre);
ItemProfile<IWorkItem> profile= getProfile(projectAreaAttribute2);
return queryClient.getResolvedExpressionResults(projectArea, term, profile);

This code snippet returns work items that contain specified attributeId but in the output it displays work item id and summary of work item. Along with this I also want to display value of custom attribute. How do I do this.
Could anyone please help me here



Thank You

0 votes



2 answers

Permanent link
This question has been answered many times here in the jazz.net forum.
Ralph's blog post explains how to retrieve the value of a custom attribute:
https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/

Basically, retrieve the custom attribute:
IAttribute someAttribute= workItemClient.findAttribute(fProjectArea, "some_attribute_ID", monitor);

Then get the Work Item attribute value:
Object value = workItem.getValue(someAttribute);

0 votes


Permanent link
Your code returns the work items that the query found and not just the Attribute. You have to get the attribute from the work item and then cast it to its type (or type handle) and return the value.

See: Understanding and Using the RTC Java Client API, https://rsjazz.wordpress.com/2012/10/29/using-work-item-queris-for-automation/ and https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/

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
× 10,938

Question asked: Sep 23 '15, 5:13 a.m.

Question was seen: 2,540 times

Last updated: Sep 23 '15, 5:53 a.m.

Confirmation Cancel Confirm